0
我有一艘太空船。我希望飞船移动到玩家触摸的区域。到目前为止,我有这样的代码:Cocos2D触摸移动到目标控件?
- (void) ccTouchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
// initialize touch
UITouch *touch = [touches anyObject];
// point out location of touch
CGPoint location = [touch locationInView:[touch view]];
// move to location
[player runAction:[CCMoveTo actionWithDuration:0.5 position:location]];
// log action
CCLOG(@"player moved");
}
但是,这有一个怪癖:当我在某些地方触摸快车将移动缓慢的,而不是向上下来,和其他怪异的动作。有什么方法可以纠正这些代码吗?
它工作得很好! – beakr