title: Projectiles/Bullets direction Cocos2d
body: <p>i am following a tutorial on a <a href="http://www.raywenderlich.com/352/how-to-make-a-simple-iphone-game-with-cocos2d-tutorial" rel="nofollow">simple cocos2d game</a>.</p>
  
  <p>however on that tutorial the bullets that the user fires is only on one direction</p>
  
  <p>what can i do to make it fire on all directions not just one sided?</p>
  
  <p>here is the code of the direction.</p>
  
  <pre><code>int offX = location.x - projectile.position.x;
  int offY = location.y - projectile.position.y;
  
  [self addChild:projectile];
  
  int realX = winSize.width + (projectile.contentSize.width/2);
  float ratio = (float) offY / (float) offX;
  int realY = (realX *ratio) + projectile.position.y;
  CGPoint realDest = ccp(realX, realY);
  
  int offRealX = realX - projectile.position.x;
  int offRealY = realY - projectile.position.y;
  float length = sqrtf((offRealX*offRealX)+(offRealY*offRealY));
  float velocity = 480/1;
  float realMoveDuration = length/velocity;
  
  [projectile runAction:[Sequence actions:[MoveTo actionWithDuration:realMoveDuration position:realDest],
                         [CallFuncN actionWithTarget:self selector:@selector(spriteMoveFinished:)], nil]];
  </code></pre>
  
  <p>all help will be greatly appreciated. Thanks</p>