如果语句逻辑不起作用,Cocos2d

时间:2012-07-05 18:59:05

标签: iphone if-statement cocos2d-iphone logic

if语句是:    //these x & y do not affect the if statement they are used for the result 6 lines down. int x = enemy.position.x; int y = enemy.position.y; NSLog(@"%G,%G", leftJoystick.velocity.x, leftJoystick.velocity.y);

if ((leftJoystick.stickPosition.x < 1 && leftJoystick.stickPosition.x > -1)&& leftJoystick.stickPosition.y > 0) {
    enemy.position = ccp(x,y-1);
    NSLog(@"North");
    return;
}

在反馈中,它显示-0.0544645,0.998516有效且记录为北,但-0.0725357,0.997366不起作用。我不明白为什么?

我正在尝试在cocos2d BTW中执行此操作。

1 个答案:

答案 0 :(得分:0)

您正在记录速度,但您的逻辑在位置上运行。清楚一点,也许答案会更清楚地告诉你。