我有2个CCLayer堆叠在一起;两者都启用触摸。我希望顶层CCLayer响应并消费触摸,底层不会对顶层消耗的触摸作出反应。支持多点触控的CCLayers,顶层不消耗触摸
顶层具有看起来像这样一个CCTouchBegan方法:
- (BOOL) ccTouchBegan:(UITouch *)touch withEvent:(UIEvent *)event
{
NSLog(@"touched!");
CGPoint location = [touch locationInView:[touch view]];
location = [[CCDirector sharedDirector] convertToGL:location];
//DO STUFF WITH TOUCH
return YES;
}
底层具有CCTouchesEnded方法,看起来像这样:
- (void) ccTouchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
//choose one of the touches to work with
UITouch *touch = [touches anyObject];
CGPoint location = [touch locationInView:[touch view]];
location = [[CCDirector sharedDirector] convertToGL:location];
//DO STUFF WITH THE TOUCH
}
结果,顶层确实不会消耗触觉,甚至不会对它们做出反应。只有底层才会响应触摸。
我们需要更多信息来回答你的问题。这些图层包含哪些内容?他们如何建立?他们在哪里被添加到屏幕上? – 2012-07-13 19:51:48
@DustinRowland完成。 – TheDanman 2012-07-13 20:55:16
@TheDanman是否重视哪个层“消耗”触摸? – 2012-07-13 21:18:59