基本上我正在创建这个游戏,并且有一个节点(球)以设定的速度绕过一条路径。设置速度在GameProcessSettings.h文件中定义,代码如下,
#define SPEED_MOVE_PLAYER_MIN 28
#define SPEED_MOVE_PLAYER_MAX 9000
现在在控制节点速度的文件中,这是代码。
- (void)moveTo:(NSString *)moveDirection currentPlayerPosition:(NSString *)playerPosition {
[self removeAllActions];
speed-= IncreaseSpeedValue;
if (speed < SPEED_MOVE_PLAYER_MIN) speed = SPEED_MOVE_PLAYER_MIN;
else {
[timer invalidate];
timer = nil;
}
SKAction *move;
if ([moveDirection isEqualToString:@"up"]) move = [SKAction moveToY:self.position.y + PLAYER_MOVE_BY_POINTS duration:speed];
else if ([moveDirection isEqualToString:@"down"]) move = [SKAction moveToY:self.position.y - PLAYER_MOVE_BY_POINTS duration:speed];
else if ([moveDirection isEqualToString:@"left"]) move = [SKAction moveToX:self.position.x - PLAYER_MOVE_BY_POINTS duration:speed];
else move = [SKAction moveToX:self.position.x + PLAYER_MOVE_BY_POINTS duration:speed];
timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(increaseSpeed) userInfo:nil repeats:YES];
IncreaseSpeedValue = -200;
[self runAction:move];
_currentMoveDirection = moveDirection;
_currentPlayerPosition = playerPosition;
}
@end
我如何以及如何使节点每秒移动得更快?