0

这是我真正想要的论点,但它不起作用。这样做的正确方法是什么?任何想法?

if (targetWithinRange == NO) {

      SKAction *move = [SKAction moveToX:-30 duration:1]; //Warning Unused Variable 'move'

}else{ //or if the target is within rang then go and hit the target

      SKAction *move = [SKAction moveTo:(CGPointMake(target.position.x, target.position.y)) duration:1];//Warning Unused Variable 'move'
 }    



 SKAction *lookingForTheTarget = [SKAction sequence:@[someAction,move,anotherAction]];

[ourSprite runAction:lookingForTheTarget];
4

1 回答 1

2

移动的范围仅在if语句中。

您可能应该将其移出if

SKAction *move;
if (targetWithinRange == NO) {
    move = ...
}
else {
    move = ...
}
于 2014-05-10T02:32:17.113 回答