cocos2dx 3.3 cocos studio的交互性问题

最近在使用cocos studio的时候,发现里面有个选项:交互性,一直没有很明白具体是啥意思。通常这种时候,看源码就对了。 交互性 新建了个cocos st

最近在使用cocos studio的时候,发现里面有个选项:交互性,一直没有很明白具体是啥意思。通常这种时候,看源码就对了。


交互性

新建了个cocos studio工程,然后在上面加了个控件,做测试。

勾选 交互性 的时候,对应的ccs文件里,会多一个属性 TouchEnable="True"

于是,第一步就完成了,这个 交互性,应该就是指控件是否支持触摸操作


源码

知道了 交互性 的意义之后,就是看实现了。

找到源码,cocos-->ui-->UIWidget-->Widget类-->setTouchEnable

void Widget::setTouchEnabled(bool enable)
{if (enable == _touchEnabled){return;}_touchEnabled = enable;if (_touchEnabled){_touchListener = EventListenerTouchOneByOne::create();CC_SAFE_RETAIN(_touchListener);// 默认吞噬触摸,可以调用setSwallowTouches接口取消吞噬_touchListener->setSwallowTouches(true);// 触摸事件处理_touchListener->onTouchBegan = CC_CALLBAC