タッチイベント取得 cocos2d-x v3
http://www.cocos2d-x.org/docs/manual/framework/native/input/event-dispatcher/en
auto touchListener = EventListenerTouchOneByOne::create();
touchListener->onTouchEnded = CC_CALLBACK_2(HelloWorld::onTouchEnded, this);
touchListener->onTouchBegan = CC_CALLBACK_2(HelloWorld::onTouchBegan, this);
_eventDispatcher->addEventListenerWithSceneGraphPriority(touchListener, this);
_eventDispatcherはNodeにあるのでそのまま使えるようです。
タッチされたかチェック
Point touchPoint = Director::getInstance()->convertToGL(touch->getLocationInView());
Node* node = this->getChildByTag( targetTag );
if ( node->getBoundingBox().containsPoint(touchPoint) ){
log("touchEnded %d" , nextNumber);
こんな感じで動きました。
- Prev スティーブ・ジョブス
- Next menuの使い方 cocos2d-x v3
- Prev cocos2d-x 始めました。1
- Next menuの使い方 cocos2d-x v3