2013-05-21 47 views
0

在我的游戏中,只有一个精灵响应触摸。无论我在屏幕上触摸什么位置,如何使鼠标联合移动此精灵/主体?通过触摸屏幕上的任何位置来移动精灵

+0

只是一直在触摸处理器是返回。通常在触摸处理程序中,在允许处理触摸之前检查触摸边界,但您可以始终返回yes,并按原样处理触摸。 – Mark

回答

0
- (void)ccTouchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { 
UITouch *touch = [touches anyObject]; 

CGPoint location = [touch locationInView: [touch view]]; 

location = [[CCDirector sharedDirector] convertToGL:location]; 

mySprite.position = location; 

} 

确保在您的init方法self.isTouchEnabled = YES;

相关问题