addTargetedDelegate in 2.2?


Hi all,
I want to enable TOUCH in cc.Node, I found these code from web:

cc.Director.getInstance().getTouchDispatcher().addTargetedDelegate(this, 0, false);

But it did not work in cocos2d-html5 2.2, an error message was given:

Uncaught TypeError: Object # has no method 'addTargetedDelegate' 

Could anyone help?
Many thanks!


Hi Yong,

cc.Director.getInstance().getTouchDispatcher().addTargetedDelegate, cc.Director.getInstance().getTouchDispatcher().addStandardDelegate
and cc.Director.getInstance().getTouchDispatcher().removeDelegate have been private, please use cc.registerTargetedDelegate, cc.registerStandardDelegate and cc.unregisterTouchDelegate instead.
for example:
cc.Director.getInstance().getTouchDispatcher().addTargetedDelegate(this, this._touchPriority, true) -> cc.registerTargetedDelegate(this._touchPriority, true, this);

more about the upgrade guide from v2.1.5 to v2.2, please look at:



It works, thank you David.


more about the upgrade guide from v2.1.5 to v2.2, please look at:

the url is not found



I’s sorry, we refactored the document’s directory, please see:

BTW, we update the event handler in v3.0, please see this: