在 cocos2d/cocos2d-x 中触及优先级 [英] Touches priority in cocos2d/cocos2d-x

查看:22
本文介绍了在 cocos2d/cocos2d-x 中触及优先级的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I am trying to play around with touches in . I have question on the priority of the touches for example , When I use CCMenuItemSprite or CCControlButtonwhich 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆