Help us understand the problem. What is going on with this article?

CocosCreatorでタッチを透過させる (swallowTouchesをfalseにする) 方法

CocosCreatorの(タッチ)イベント登録について

非公開Apiを用いて設定する

どうにもならないので、昔公開されていた非公開のApiを使用して設定しました
TypeScriptで書いてるので必要に応じてJSに戻すなどしてください

const listener1 = cc.EventListener.create({
    event: cc.EventListener.TOUCH_ONE_BY_ONE,
    swallowTouches: false,
    onTouchBegan: (touch: cc.Touch, event) => {
        // Node内をtapしているかでtrue/false切り替えても良い
        return true;
    },
    onTouchEnded: (touch, event) => {
        // 発火した上で透過させたい処理
    }
});
cc.eventManager.addListener(listener1, this.touchNode);

非公開なので、 EventListener や eventManager部分が赤くなったり下記警告が出力されます。

Simulator: JS: [WARN]: The 'cc.eventManager' will be removed in v2.0, please use 'cc.EventTarget or cc.systemEvent' instead.

公式も明確に cc.eventManager を使わないでくれと言っています
- http://docs.cocos2d-x.org/creator/api/en/classes/Node.html#on
- It's the recommended way to register touch/mouse event for Node,
please do not use cc.eventManager directly for Node.

いつ使えなくなるかはわかりませんが現状の対応ということで

atr-toru
Unity, CocosCreator, Cocos2d-xでアプリ開発してます 元インフラエンジニア ニッチでも誰かの役に立ちそうな情報を載せたいと思っています
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした