从操纵杆输入增加角色速度?

时间:2013-11-20 17:07:28

标签: ios sprite-kit joystick

现在我有一个可操作的操纵杆,但我想提高角色的速度。 我现在正在使用这个:http://roadtonerdvana.wordpress.com/2013/09/20/jcinput-a-simple-joystick-for-sprite-kit/ 我附加了一个Imagefile作为移动对象,但它对我来说太慢了。 我在哪里以及如何改变速度?

1 个答案:

答案 0 :(得分:0)

如果您阅读该帖子,您将知道操纵杆返回x和y值,每个值的范围为-1到1.

每次移动操纵杆时,它的属性x和y都会相应地改变,最大值为1,最小值为-1。

在更新方法中,您可以执行以下操作来调整速度:

-(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)];


}