タッチイベント取得 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);

こんな感じで動きました。

This entry was posted on 木曜日, 3月 13th, 2014 at 6:59 PM and is filed under cocos2d-x. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.

Unityによるゲームを公開しております iOS/Android
https://itunes.apple.com/jp/app/lost-knight-3d-action/id900917032
https://play.google.com/store/apps/details?id=com.groundroad.runknight

各種開発支援・機能開発等小さいお仕事などもお請けしております。
unity開発支援, PHPシステム開発, javascript/html5 フロント開発, titanium mobileアプリ開発
お気軽にお問い合わせください
大崎・五反田近郊での対面でのお打ち合わせはいつでも可能です。