Posted: 8th Sep 2011 18:58
i cant find this code anywhere plaese help. how do i fade a sprite?
Posted: 8th Sep 2011 20:15
Hello....

May be you can try to fade a sprite playing with alpha with the SetSpriteColorAlpha command.
Posted: 8th Sep 2011 20:35
SetSpriteColorAlpha(spriteNum, alpha)

0 alpha is fully transparent, 255 is fully opaque.
Posted: 8th Sep 2011 20:44
Thanks also do you know how to set a time gap between each code? I want to make it so that when one sprite hits another it one the sprite bounces off and the sprite that is hit no longer exists
Posted: 8th Sep 2011 21:06
Replace the spriteID with the number of the sprite you are working with.

for f = 255 to 0 step -1
      SetSpriteColorAlpha(spriteID, f)
      sync()
      sleep(f)
next f

It may take a second or two to start doing its thing.
If it gives you any trouble then take the sleep(f) line out.


Here is another way that won't pause your main loop...

Global mlc
mlc = 0
Global f
f = 255

// main loop
do
    mlc = mlc + 1
    If mlc > 9
        mlc = 0
        f = f - 1
        if f < 0 then f = 0
        SetSpriteColorAlpha(spriteID, f)
    endif
sync()
loop


Now, the reduction of f is only happening every tenth time through the main loop thanks to the main loop counter (mlc).
Depending on the speed of your main loop, you would adjust the number 9 in the 'if mlc > 9' line, so it would do it more or less often.
Or, you could take off more than 1 in the fade as in... f = f - 5

Setting the 9 to 3 and the 1 to 5 seems to work nicely in my test.
Give that a whirl and see what happens.