这是我真正想要的论点,但它不会起作用。这样做的正确方法是什么? 任何想法?
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];
答案 0 :(得分:2)
移动范围仅在if
声明中。
您应该将其移出if
:
SKAction *move;
if (targetWithinRange == NO) {
move = ...
}
else {
move = ...
}