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?
Asked
Active
Viewed 177 times
0
-
What platform does this apply to? (please update the tags) – trojanfoe Nov 20 '13 at 17:14
-
It´s from a sprite kit template. – user3010148 Nov 20 '13 at 17:55
-
Sure, but Sprite Kit and cocos2d is supported under both iOS and OSX, so which platform are you asking about? – trojanfoe Nov 20 '13 at 21:59
1 Answers
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
-
If i insert your lines it says that i use an unused variable "speedX" and "speedY"... – user3010148 Nov 21 '13 at 12:39
-
It won't say that if you modify that 3rd line in the method as I have done. – prototypical Nov 21 '13 at 16:58