title: CCMoveTo doesn't get the updated player postition.....(iphone,cocos2d)
body: <p>I'm adding an enemy like this:</p>
  
  <pre><code>-(void)addEnemy {
      if ([spawnedEnemies count] &lt; 25) {
          CCSprite* sprite = [CCSprite spriteWithFile:@"white.png"];
          float randomX = arc4random() % 480;
          float randomY = arc4random() % 320;
  
          sprite.position = ccp(randomX,randomY);
          [spawnedEnemies addObject:sprite];
          [self addChild:sprite];  
  
          [sprite runAction:[CCMoveTo actionWithDuration:5 position:player.position]];
      } }
  </code></pre>
  
  <p>but if my player moves the sprite still moves to the last player position...
  because of that i tried this in my tick:</p>
  
  <blockquote>
    <p>-(void)tick:(ccTime)delta {</p>
  
  <pre><code>for (CCSprite *sp in spawnedEnemies) {
      [sp stopAllActions];
      [sp runAction:[CCMoveTo actionWithDuration:5
  </code></pre>
    
    <p>position:player.position]];
        } }</p>
  </blockquote>
  
  <p>but the enemies will only move if i stop moving (there just moving reallllllllyyyyyyyyy slow because every time i move it calls [sp stopAllActions]</p>
  
  <p>What should I do now?</p>
  
  <p><strong>EDIT:*</strong><em>EDIT:<strong></em>*EDIT:*</strong><em>EDIT:<strong></em>*EDIT:*</strong><em>EDIT:<strong></em>*EDIT:*</strong><em>EDIT:<strong></em>*EDIT:</strong>
  Now I'm doing this and the enemies are moving to the player even if the player is moving
  but there's a problem: the nearer the enemy (is to the player) the slower they are moving...
  How to solve this?</p>
  
  <pre><code>//function to apply a velocity to a position with delta
  static CGPoint applyVelocity(CGPoint velocity, CGPoint position, float delta){
      return CGPointMake(position.x + velocity.x * delta, position.y + velocity.y * delta);
  }
  
  
  -(void)tick:(ccTime)delta {    
      for (CCSprite *sp in spawnedEnemies) {
          CGPoint m = ccpSub(player.position, sp.position);
          sp.position = applyVelocity(m, sp.position, 1.0/60.0f);
      }
  }
  </code></pre>