在 cocos2d/cocos2d-x 中触及优先级 [英] Touches priority in cocos2d/cocos2d-x
问题描述
I am trying to play around with touches in cocos2d-x . I have question on the priority of the touches for example , When I use CCMenuItemSprite
or CCControlButton
which are added on the Layer which has setTouchEnabled(true)
or even If I put a
What I found is touch is not first given to ccTouchesBegan
(...I mean Layer) instead it is taken by CCMenuItemSprite
or CCCOntrolButton
call backs .
Moreover , If I add an extra layer top on all the layers and setTouchEnable
(True) same results I get
touches are first given to menuitem and control button which after touch swallows the touches.
Is there any way by which we can change the priority of touches ? or
Is there any way by which I can override CCControlButton
or CCMEnuItemSprite
...ccTouchesBegan or moved
after all I want the touch location of CCMenuItem
or CControlButton
otherwise I have to reconsider the CCSprite
?
overwrite your CCLayer's method
YOUR_LAYER::registerWithTouchDispatcher{
CCTouchDispatcher::sharedDispatcher()->addTargetedDelegate(this, INT_MIN, true);
}
这篇关于在 cocos2d/cocos2d-x 中触及优先级的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!