0

Now i have a working Joystick, but I want to increase the characters speed. I´m using this one at the moment: http://roadtonerdvana.wordpress.com/2013/09/20/jcinput-a-simple-joystick-for-sprite-kit/ I attached an Imagefile as the moving object, but it´s way too slow for my purpose. Where and how can I change the speed?

prototypical
  • 6,731
  • 3
  • 24
  • 34
user3010148
  • 29
  • 1
  • 1

1 Answers1

0

If you read the post you'll know that the joystick returns a x and y value, each ranging from -1 to 1.

Every time you move the joystick, the properties x and y of it change accordingly, the maximum value is 1 and the minimum is -1.

In the update method, you could do something like this to adjust the speed :

-(void)update:(CFTimeInterval)currentTime {

    // I'm using the magic number of 5 as an example of how to magnify the speed x5
    float speedX = 5 * self.joystick.x;
    float speedY = 5 * self.joystick.y;

    [self.myLabel setPosition:CGPointMake(self.myLabel.position.x+speedX, self.myLabel.position.y+speedY)];


}
prototypical
  • 6,731
  • 3
  • 24
  • 34