在cocos2d / cocos2d-x中触摸优先级 [英] Touches priority in cocos2d/cocos2d-x
问题描述
我试图在 cocos2d-x 。我有关于触摸的优先级的问题,例如,当我使用 CCMenuItemSprite
或 CCControlButton
它有 setTouchEnabled(true)
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)
甚至如果我放一个
我发现是不是首先给予 ccTouchesBegan
(...我的意思是层)而是由 CCMenuItemSprite
或 CCCOntrolButton
回拨
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 .
此外,如果我在所有图层上添加一个额外的图层顶部和 setTouchEnable
(True)相同的结果我得到
触摸首先被给予菜单和控制按钮,触摸后吞咽触摸。
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.
任何方式,我们可以改变触摸的优先级?或
有任何方式可以覆盖 CCControlButton
或 CCMEnuItemSprite
... ccTouchesBegan或移动
毕竟我想要触摸 CCMenuItem
或 CControlButton
的位置,否则我必须重新考虑 CCSprite
?
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
?
推荐答案
覆盖您的CCLayer方法
overwrite your CCLayer's method
YOUR_LAYER::registerWithTouchDispatcher{
CCTouchDispatcher::sharedDispatcher()->addTargetedDelegate(this, INT_MIN, true);
}
这篇关于在cocos2d / cocos2d-x中触摸优先级的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!