【发布时间】:2014-02-12 00:26:10
【问题描述】:
我的场景中有一个对象。当我触摸屏幕时,我希望对象的 y 位置成为我触摸的 y 位置。为此,我有以下代码:
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
SKNode *player = [self childNodeWithName:@"player"];
UITouch *touch = [touches anyObject];
CGPoint positionInScene = [touch locationInNode:self];
player.position = CGPointMake(player.position.x, positionInScene.y);
}
它适用于这段代码,但我如何让对象以稳定的速度移动到触摸 y 位置?因此,不要跳到触摸 y 位置,而是以预定义的速度移动到它。
【问题讨论】:
标签: ios objective-c sprite-kit