Simplest way to make a sprite blink

SGDK only sub forum

Moderator: Stef

Post Reply
matasiete
Interested
Posts: 10
Joined: Thu Jan 25, 2018 6:21 pm
Location: Spain
Contact:

Simplest way to make a sprite blink

Post by matasiete » Sun Nov 24, 2019 6:09 pm

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?

hotrodx
Very interested
Posts: 50
Joined: Thu Mar 21, 2019 1:23 pm

Re: Simplest way to make a sprite blink

Post by hotrodx » Sun Nov 24, 2019 7:16 pm

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);

matasiete
Interested
Posts: 10
Joined: Thu Jan 25, 2018 6:21 pm
Location: Spain
Contact:

Re: Simplest way to make a sprite blink

Post by matasiete » Mon Nov 25, 2019 7:09 pm

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.

Post Reply