Cocos creator touch event

hello, how i can move node(sprite) like cocos 2dx in cocos creator dynamically.(wanted to know touch began ,touch move and touch end event ) in cocos creator.

https://docs.cocos.com/creator/manual/en/scripting/internal-events.html

For example:

this.node.on(cc.Node.EventType.TOUCH_MOVE, (ev: cc.Event.EventTouch) => {

}, this);

hi thanks for your response. is this work for 3.4.2?? i have did that way. but it isn’t working.
start () {

    //this.node.on(Node.EventType.TOUCH_MOVE, this.onEventMove,this);

  }

onEventMove(even)
{
console.log(“started”);
let worldPoint1 = even.getLocation();

}

i can able to get coordinator smoothly but how i can directly move the nods?? if i was pass directly coordinator to any node then position of node directly get out of screen. did not get exact touch location… (note - node added directly in canvas)

this.node.setPosition(worldPoint1.x, worldPoint1.y);

this is working but touch of any node i was getting from far distance… because convertToNodeSpace not working in 3.4.2. could you please help me to solve this issue.if there will be any example then please could you able to post here.

You can get the UITransform first, then use convertToNodeSpace in v3.4.2.

@linrm can you please give me example for that i didn’t able to get you. sorry for delayed in response i am in some other work.

this.touchNode.getComponent(UITransform).convertToNodeSpaceAR(point); refer to :CocosCreatorAPI

@linrm thanks

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.