我还需要在 HUDLayer 和 GameLayer 中进行触摸检测。
因为当 player.position > 480 时,用户无法与 GameLayer 正常交互。
触摸位置与 HUDLayer 相关,这很好,但我需要在两个图层上都进行触摸。我在两层都尝试了启用触摸的 ccTouchesBegan 方法,但 Log 仍然显示相同的触摸位置两次。我怎样才能做到这一点?
游戏层.mm
- (void) ccTouchesBegan(NSSet *)touches withEvent:(UIEvent *)event
{
for(UITouch *touch in touches ) {
CGPoint location = [touch locationInView: [touch view]];
location = [CCDirector sharedDirector] convertToGL: location];
NSLog(@"Touch X: %f Y: %f", location.x, location.y);
}
}