大家好。
我在场景编辑器中设置了一个触发器在触摸的时候播放骨骼动画,还有一个触发器在场景初始化时播放骨骼动画,在模拟器中运行是可以触发的。
但是导出资源到cocos2d-x 3.2 cpp工程中,却都不能触发。请问如何解决这个问题?
你好,这个需要添加对触发器功能的设置,这里有一些参考资料,请查阅:
http://www.cocoachina.com/bbs/read.php?tid=196660
搞定了。
昨天是把Cocos Studio 1.6 生成的Trigger代码放到Class目录下,在 CMakeLists.txt里面 set(GAME_SRC 里面添加响应的cpp文件名称,执行 cmake CMakeLists.txt 重新生成makefile。
刚才参照第三个链接,在代码中这样弄,要自己去发送事件的。。
#include "Trigger/EventDef.h"
Node *pNode = SceneReader::getInstance()->createNodeWithSceneFile("publish/FightScene.json");
this->addChild(pNode);
auto touchListener = EventListenerTouchOneByOne::create();
touchListener->setSwallowTouches(true);
touchListener->onTouchBegan = ](Touch* touch, Event* event){
CCLOG("touch down");
sendEvent(TRIGGEREVENT_TOUCHBEGAN);
return true;
};
Director::getInstance()->getEventDispatcher()->addEventListenerWithSceneGraphPriority(touchListener, pNode);