Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cocos2d getting a sprite to blink, it becomes invisible

im trying to make my sprite blink, but it just disappears, i have searched google, but i cant find a solution, heres what im doing:

    CCBlink * blinker = [CCBlink actionWithDuration: 0.5 blinks: 1];  
 [player runAction: blinker];

this method is called when two of my sprites collide, when the collision takes place, i want the 'player' sprite to blink for a few seconds. at the moment, when the sprites collide, the 'player' sprite becomes invisible....thanks

like image 374
sahil Avatar asked Feb 12 '12 14:02

sahil


1 Answers

CCBlink seems to work by toggling the visibility of your sprite on and off a given number of times within the stated duration you gave it. Depending on the duration you set, you might sometimes end up with an "off" visibility state at the end of the action (very buggy yeah, I had that too before), which isn't quite desired.

Two suggestions: (1) Play around with the number of blinks. (2) Always force the sprite to be visible at the end of the blink:

Add: [CCShow action] to the end of your blink action. You can string both actions into a CCSequence.

like image 143
Ken Toh Avatar answered Nov 02 '22 06:11

Ken Toh