Node.on('touchstart', callBack) => touch.get ID() = undefined


#1

Hi Cocos Creator team !

I’m handling with touches & I need to distinguish touches. In earlier version of Creator (1.52) I can still see touch.getID() returns a numeric ID. But recently in Creator 1.8 I can’t.

cc.find('Canvas').on('touchstart', function(event){
         console.log( event.touch.getID() ); // log "undefined"
});

Instead I can see touch.___instanceId indicates the unique ID for each touch.

So Creator team please help me with a clear answer, is it a bug or a feature?
I’m developing web-mobile app. Thanks !


#2

It works for me

this.node.on(cc.Node.EventType.TOUCH_START, this.onTouchStart);

onTouchStart = (event: cc.Event.EventTouch) => {
    this.touches[event.touch.getID()] = event.touch;
}