ios - Cocos2d: How to stop clicking buttons of lower z order layer from upper z order layer? -
i developing cocos2d game have cclayer named gameplaylayer , cclayer named shoplayer. shoplayer fullscreen layer. gameplaylayer touchenabled , has multiple buttons (ccmenuitemimage). shoplayer accessed shop button has following @selector.
(void) onclickshop { shoplayer * shop = [[shoplayer alloc] init]; [self addchild:shop z:40]; }
to stop touch propagation used cctouchonebyonedelegate , following methods in shoplayer.
(void) onenter { [[[ccdirector shareddirector] touchdispatcher] addtargeteddelegate:self priority:0 swallowstouches:yes]; [super onenter]; } (void) onexit { [[[ccdirector shareddirector] touchdispatcher] removedelegate:self]; [super onexit]; } (bool) cctouchbegan:(uitouch *)touch withevent:(uievent *)event { return yes; }
now stops cctouchesbegan of gameplaylayer called fine. cannot stop other buttons of gameplaylayer called. when touch @ positions buttons of gameplaylayer placed, called though can not see them.
so question how stop clicking buttons of lower layer upper layer?
use kccmenuhandlerpriority
touch priority
[[[ccdirector shareddirector] touchdispatcher] addtargeteddelegate:self priority:kccmenuhandlerpriority swallowstouches:yes];
Comments
Post a Comment