我一直在按照本教程创建基于图块的地图并让角色四处移动。然后我按照本教程为运动添加精灵动画。我想出了类似以下的运动:
[self stopAction: cameraMoveAction];
[playerSprite stopAction:playerMoveAction];
[playerSprite runAction: targetAction];
self.playerMoveAction = [CCSequence actions:
[CCMoveTo actionWithDuration: MOVEMENT_SPEED * 4 position: newPosition],
[CCCallFunc actionWithTarget: self selector: @selector(finishedMoving)],
nil
];
self.cameraMoveAction = [CCSequence actions:
[CCMoveTo actionWithDuration: MOVEMENT_SPEED * 4 position: [self calculateNewCenterOfScreen: newPosition]],
nil
];
[self runAction: cameraMoveAction];
[playerSprite runAction: playerMoveAction];
所以如果你看到了,我正在移动玩家和相机(为了让玩家始终居中)。我也曾尝试在finishedMoving
通话中将摄像头对准玩家,但这看起来很糟糕(玩家会移动,然后摄像头会猛拉到玩家的位置)。
有没有更好的方法来做到这一点?