13
13

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

setTouchEnabledがDeprecatedって言われたけどんじゃどうするんじゃい

Last updated at Posted at 2014-02-17

正解:イベントリスナーを設定してあげる。
\パパーン/

TouchLayer.cpp
bool TouchLayer::init(){
//TouchOneByOneの他にTouchAllAtOne(複数タッチ)もあるお!
auto listener = EventListenerTouchOneByOne::create();
//でもAllAtOnceならonTouch"es"Beganになる。
 listener->onTouchBegan = CC_CALLBACK_2(TouchLayer::onTouchBegan, this);
 listener->onTouchMoved = CC_CALLBACK_2(TouchLayer::onTouchMoved, this);
 listener->onTouchEnded = CC_CALLBACK_2(TouchLayer::onTouchEnded, this);
 

//cocos2d-x3.0からは見たまんまのタッチの優先度とかに設定できるから便利だよね。
this->getEventDispatcher()->addEventListenerWithSceneGraphPriority(listener, this);
}

なんかObjectiveCのprotocol作ってDelegate設定し直してるみたいな感じよね。ラムダ式とか
簡単な処理なら突っ込んでもできそうだけども。

13
13
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
13
13

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?