Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

Starsector 0.97a is out! (02/02/24); New blog post: Simulator Enhancements (03/13/24)

Author Topic: Is there any way to change the transparency of missiles in combat?  (Read 718 times)

cjy4312

  • Ensign
  • *
  • Posts: 40
    • View Profile

Hi,I'm making a honeycomb shield these days. now I had some trouble.

I'm using fighter wings with "setExtraAlphaMult" as shield blocks. when these blocks take any damage, They will glow.
(This way causes serious FPS loss when shield deploying on large(veeeeeery Large) ship, there is so many ships deployment tips)

I was trying to use BOMBs with SHIP CollisionClass instead of them,but  missile.getSpriteAPI().setAlphaMult(float) is notwork in combat(Maybe there's something wrong  I use this code.)
How does this code work? ::)

[attachment deleted by admin]
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23989
    • View Profile
Re: Is there any way to change the transparency of missiles in combat?
« Reply #1 on: October 05, 2019, 11:41:00 AM »

I think if you call missile.setTimeSinceFizzling() that should let you do it. The alpha of the sprite is set according to:

brightness = (flameoutTime- timeSinceFizzling) / fadeTime;
if (brightness > 1) brightness = 1;
if (brightness < 0) brightness = 0;

"fadeTime" is specified in the missile projectile file and defaults to 0.5. flameoutTime is also specified there and defaults to 4.

So if in your missile you had:
"fadeTime":1,
"flameoutTime":1,

Then:
missile.setTimeSinceFizzling(1) should set alpha to 0 (but it might also make the missile despawn, so would have to be careful)
missile.setTimeSinceFizzling(0) should set alpha to 1

Etc.
Logged

cjy4312

  • Ensign
  • *
  • Posts: 40
    • View Profile
Re: Is there any way to change the transparency of missiles in combat?
« Reply #2 on: October 05, 2019, 11:57:53 AM »


Then:
missile.setTimeSinceFizzling(1) should set alpha to 0 (but it might also make the missile despawn, so would have to be careful)
missile.setTimeSinceFizzling(0) should set alpha to 1

Etc.

 :) Thank you very much!
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23989
    • View Profile
Re: Is there any way to change the transparency of missiles in combat?
« Reply #3 on: October 05, 2019, 12:05:34 PM »

Hope it works, I haven't tried it :)
Logged

cjy4312

  • Ensign
  • *
  • Posts: 40
    • View Profile
Re: Is there any way to change the transparency of missiles in combat?
« Reply #4 on: October 07, 2019, 02:43:00 AM »

Hope it works, I haven't tried it :)
:P
Unfortunately, it's not work on missiles.
but no problem,  I can spawn a *normal* projectile when I need glow effect ;D
Logged