How to set a respawn system in cocos2d that is based on a timer?

I want to respawn enemy sprites based on a timer any suggestions would be appreciated. Would be great if you show me some code examples.

   -(void)addEnemyAtX:(int)x y:(int)y {
  CCSprite *enemy = [CCSprite spriteWithFile:@"enemy1.png"];
  enemy.position = ccp(x, y);
  [self addChild:enemy];
  [self animateEnemy: enemy];}


  - (void) enemyMoveFinished:(id)sender {
CCSprite *enemy = (CCSprite *)sender;

    [self animateEnemy: enemy];
 }// a method to move the enemy 10 pixels toward the player
 - (void) animateEnemy:(CCSprite*)enemy
    {
    // speed of the enemy
     ccTime actualDuration = 0.3;

     // Create the actions
        id actionMove = [CCMoveBy actionWithDuration:actualDuration
                                                    position:ccpMult(ccpNormalize(ccpSub(player.position,enemy.position)), 10)];
     id actionMoveDone = [CCCallFuncN actionWithTarget:self
                                         selector:@selector(enemyMoveFinished:)];
          [enemy runAction:
                 [CCSequence actions:actionMove, actionMoveDone, nil]];



         }

Answers


I think you should learn the basics of Cocos2D first ;) It's pretty well covered in the book "Learning Cocos2D" - I recommend it! Nevertheless here is the line of code you want, I doubt though, that it is useful ;)

action = [CCSpawn actions:
          [CCAnimate actionWithAnimation:animation
break;
restoreOriginalFrame:NO],
[CCMoveTo actionWithDuration:2.4f
 position:ccp([self position].x +
 nil];
xPositionOffSet,
[self position].y)],

Need Your Help

Why does adding @Transactional causes exception org.springframework.beans.factory.BeanCreationException: Error creating bean with name?

spring hibernate spring-mvc transactions

I am learning Spring with Hibernate and I am playing a bit with my configuration to fully understand how it works. An answer to this will be quite helpful to understand what is going on. I have qui...