8

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

sahil
  • 141
  • 1
  • 9

3 Answers3

3

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.

Ken Toh
  • 3,721
  • 1
  • 24
  • 30
  • +1 this works. just what i needed. (funny that i came across this two weeks ago when i suggested to OP to accept an answer, and now i use it) – phlebotinum Mar 02 '12 at 10:57
0

Blink action is buggy. I always use the following to guarantee that the object remains visible at the end of the animation:

Sequence* action = Sequence::create(Blink::create(BLINK_DURATION, BLINK_TIMES), Show::create(), NULL);
Pedro Soares
  • 1,117
  • 12
  • 14
0

Verify that when (and where) you process 'onCollision' types of events you do not remove the sprite from its parent.

YvesLeBorg
  • 9,070
  • 8
  • 35
  • 48
  • yep, when the sprites collide, nothing happens, i only want the player sprite to blink, so i have put the above code in the `if (if (CGRectIntersectsRect(playerRect, rockRect)0` – sahil Feb 12 '12 at 15:22