title: Cocos2D setvisible =no after animation finishes
body: <p>In my code asteroids coming toward to the ship,
  I want to implement  explosion animation if laser hits the asteroid. 
  Asteroid should run explosion animation and switch to invisible mode.</p>
  
  <p>Without animation when target is hit, target successfully switches to invisible mode. Without setting object to  invisible, animation runs great. When I put it together because of procedural code without seeing animation it quickly set object to invisible.</p>
  
  <p>How can I both see the animation then set it to invisible mode. (targets aka asteroids are in various speeds some of them are too fast while others slow)
  The idea to put target to invisible is prevent them hitting to ship.</p>
  
  <p>I tried this question&amp;answer <a href="https://stackoverflow.com/questions/4174445/cocos2d-autoremove-sprite-after-animation">cocos2d autoremove sprite after animation</a> didnt work</p>
  
  <pre><code>for (CCSprite *asteroid in _asteroids) 
  {        
       if (!asteroid.visible) continue;
  
          for (CCSprite *shipLaser in _shipLasers)
          {                        
              if (!shipLaser.visible) continue;
  
              if (CGRectIntersectsRect(shipLaser.boundingBox, asteroid.boundingBox)) 
              {                
                  [[SimpleAudioEngine sharedEngine] playEffect:@"explosion_large.caf"];
  
                  //explosion zombie animation starts 
                  NSMutableArray *walkAnimFrames = [NSMutableArray array];
                  for(int i = 1; i &lt;= 12; ++i) 
                  {
                      [walkAnimFrames addObject:
                       [[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:
                        [NSString stringWithFormat:@"zombieexplodes%d.png", i]]];
                  }
                  CCAnimation *walkAnim = [CCAnimation 
                                           animationWithFrames:walkAnimFrames delay:0.1f];
  
  
                  _dieAction = [CCRepeatForever actionWithAction:
                                 [CCAnimate actionWithAnimation:walkAnim restoreOriginalFrame:NO]];
  
                  [asteroid runAction:_dieAction];
                  //explosion zombie ends
  
                  [self addPoint];
  
                  //change meme to woohoo.png   
                  [_ship setDisplayFrame:[[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName: @"woohoo.png"]];
  
                  shipLaser.visible = NO;
                  [asteroid setDisplayFrame:[[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName: @"zombieexplodes13.png"]];
                  //asteroid.visible=NO;
  
  
                  continue;
              }
          }
  }
  </code></pre>