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