hello, i’m very begginer in javascript and cocos creator.
i want to ask how can i detect when i stop drag/move node but, my finger still touch screen?
here is my code :
CC does it’s best to send across every TOUCH_MOVE event captured by the native JS listener.
So for most cases, the last 2 touch move event s will have the same touch._point coordinates.
They also have touch._prevPoint.
So you can either store the previous touch location yourself, detect that it’s the same point values as the new location, or use the _prevPoint points and compare to them _point; and that means the user is still touching the screen but they have stopped moving.
Once they release their finger from t he screen you get a TOUCH_END event, but if there is no movement for say 3 seconds between the last TOUCH_MOVE and the TOUCH_END then you will not recieve any events but the user is still touching the screen.
setup some code like this to debug and test out what you get:
onLoad: function () {
this.node.on(cc.Node.EventType.TOUCH_START, this.onTouchStart, this);
this.node.on(cc.Node.EventType.TOUCH_MOVE, this.onMoveTouch, this);
this.node.on(cc.Node.EventType.TOUCH_END, this.onTouchEnd, this);
},
onTouchStart: function (event) {
console.log('Touch Start', event);
},
onMoveTouch: function (event) {
console.log('touch move', event);
},
onTouchEnd: function (event) {
console.log('touch end', event);
},