title: How to use a SneakyJoystick to shoot bullets (cocos2d for iphone)?
body: <p>I want to use a sneakyjoystick to shoot bullets. Every time the joystick is active it should shoot a bullet from the player into the direction that the joystick points.</p>
  
  <p>How can I do that? </p>
  
  <p>PS: It would be great if someone could explain the code. I want to understand it ;)</p>
  
  <p><strong>Edit</strong>:</p>
  
  <pre><code>static CGPoint applyVelocity(CGPoint velocity, CGPoint position, float delta){
      return CGPointMake(position.x + velocity.x * delta, position.y + velocity.y * delta);
  }
  -(void)canShootWithRightJoystick { //called in tick method
      if (hudLayer.rightJoystick.velocity.x != 0 &amp;&amp; hudLayer.rightJoystick.velocity.y != 0) {
  
          CCSprite* sp = [CCSprite spriteWithFile:@"red.png"];
          sp.position = player.position;
          [self addChild:sp z:10];
  
          CGPoint vel = hudLayer.rightJoystick.velocity;
          CCLOG(@"%.5f //// %.5f",vel.x,vel.y);
          vel = ccpMult(ccpNormalize(vel), 50);
          sp.position = applyVelocity(vel,player.position, 50);
  
      }
  }
  </code></pre>
  
  <p>But nothing happens :(</p>