【发布时间】:2013-05-21 11:13:13
【问题描述】:
在我的游戏中,只有一个精灵响应触摸。无论我在屏幕上的哪个位置触摸,如何让鼠标关节移动这个精灵/身体?
【问题讨论】:
-
在触摸处理程序中总是返回yes。通常在触摸处理程序中,您会在允许处理触摸之前检查触摸边界,但您可以始终返回 yes,并按原样处理触摸。
标签: ios cocos2d-iphone box2d box2d-iphone uitouch
在我的游戏中,只有一个精灵响应触摸。无论我在屏幕上的哪个位置触摸,如何让鼠标关节移动这个精灵/身体?
【问题讨论】:
标签: ios cocos2d-iphone box2d box2d-iphone uitouch
- (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;
【讨论】: