Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: [0.9.1a RC8]bugReport: ship.setSprite in Hullmod is not working properly  (Read 308 times)

cjy4312

  • Ensign
  • *
  • Posts: 28
    • View Profile
    • Email

Hi Alex!
I had some problems when I using ship.setSprite() in Hullmod. :P
I'm trying to use this code to change my ship's sprite and flux dissipation when all wings removed.
Code
public void applyEffectsAfterShipCreation(ShipAPI ship, String id){
        if(ship.getVariant().getWings().isEmpty()){
            ship.setSprite("CTB_Ship", "ctb_mycarrier_redrunway");
            ship.getMutableStats().getFluxDissipation().modifyMult(id, 2f);
        }else{
            ship.getMutableStats().getFluxDissipation().unmodify(id);
        }
    }
The ship is rendered in the wrong position when I removed all wings
(I must reselect the ship then it will set "redrunway" sprite and increase flux dissipation,but when I re-added any wing to the ship,sprite and flux dissipation will be reset immediately. )/(picture.a&picture.b)

There is another issue when ship join battle with no wings,I don't know how to describe it,as shown in picture.c

I uploaded a video to show these issues:
https://www.bilibili.com/video/BV1eK4y1f7BV
Logged

cjy4312

  • Ensign
  • *
  • Posts: 28
    • View Profile
    • Email
Re: [0.9.1a RC8]bugReport: ship.setSprite in Hullmod is not working properly
« Reply #1 on: November 29, 2020, 11:34:12 AM »

oh no  :-[
I forgot test this code in Campaign

I even tried move this code into advanceInCombat.  maybe ".setSprite" is not worked in Campaign? :-[


« Last Edit: November 29, 2020, 12:00:13 PM by cjy4312 »
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 17396
    • View Profile
Re: [0.9.1a RC8]bugReport: ship.setSprite in Hullmod is not working properly
« Reply #2 on: November 29, 2020, 11:56:19 AM »

Hi! It looks like you're probably not setting the sprite's center? Assuming the replacement sprite is the same size as the original - which iirc it needs to be - the center needs to be set to be the same as the original sprite.

newSprite.setCenter(oldSprite.getCenterX(), oldSprite.getCenterY())

Or some such...
Logged

cjy4312

  • Ensign
  • *
  • Posts: 28
    • View Profile
    • Email
Re: [0.9.1a RC8]bugReport: ship.setSprite in Hullmod is not working properly
« Reply #3 on: November 29, 2020, 12:02:29 PM »

I changed “wolf_Starting”  to get my ship in campaign, when ship created by "no wing" variant,It looked like pic.b.
when I add a wing ,sprite and flux dissipation will be reset but not turn back again after I remove that wing :(
« Last Edit: November 29, 2020, 12:14:35 PM by cjy4312 »
Logged

cjy4312

  • Ensign
  • *
  • Posts: 28
    • View Profile
    • Email
Re: [0.9.1a RC8]bugReport: ship.setSprite in Hullmod is not working properly
« Reply #4 on: November 29, 2020, 12:08:32 PM »

but setCenter is worked,thank you!
Logged

cjy4312

  • Ensign
  • *
  • Posts: 28
    • View Profile
    • Email
Re: [0.9.1a RC8]bugReport: ship.setSprite in Hullmod is not working properly
« Reply #5 on: November 29, 2020, 12:23:10 PM »

Hi! It looks like you're probably not setting the sprite's center? Assuming the replacement sprite is the same size as the original - which iirc it needs to be - the center needs to be set to be the same as the original sprite.

newSprite.setCenter(oldSprite.getCenterX(), oldSprite.getCenterY())

Or some such...
setCenter worked,thank you!
but setSprite is still not working in campain
I tried use shipsystem to run that code in campain combat, it's okay,but it just not work in Hullmod.applyEffectsAfterShipCreation  :(
Logged