Page 1 of 1

Simplest way to make a sprite blink

Posted: Sun Nov 24, 2019 6:09 pm
by matasiete
I have a 2x2 sprite and I want it to blink.

I've tried duplicating the width of the image and leaving a 2x2 black area in the right, but this doesn't make the job.

SPRITE nuke_sprite "sprite/nuke.png" 2 2 NONE 15

I guess this doesn't work because the following rescomp behavior:
- rescomp detects empty frame at end of animation row to not store empty frame data.
What's the easiest way to make the sprite blink?

Re: Simplest way to make a sprite blink

Posted: Sun Nov 24, 2019 7:16 pm
by hotrodx
Use SPR_setVisibility. Then on the second parameter, alternate between VISIBLE and HIDDEN

If you manage your own tick count (i.e. increments every cycle), you can do something like:

SPR_setVisibility(sprite, SYS_COUNTER & 1 ? HIDDEN : VISIBLE);

Re: Simplest way to make a sprite blink

Posted: Mon Nov 25, 2019 7:09 pm
by matasiete
Thanks, yes, using SPR_setVisibility is straighforward, but if forces me to handle manually the counter and the visibility flag. I assumed there would be a way to move the responsibility to the sprite engine since it does basically the same thing when it handles automatically animation frames.