Are you inheriting from component? Can you show me your whole instantiating code for this child node? Try this.node.runAction() or this.getComponent(cc.Node).runAction();
on these situations, a node can run action(objects that inherit cc.Node have a method called ‘runAction’):
1.node is in the render tree
2.node’s active is true
your code this.runAction, the ‘this’ in this line is a function, not a node, so this.runAction can’t work.
when a function{}.bind(this) , ‘this’ in the function is no longer the function, but the component,
so ‘this.node’ means the node that attached to this component. so this.node has the ‘runAction’ method.
by the way, if you don’t want to use ‘bind(this)’, you can also try this one:
onLoad: function () {
this.node.parent.on(‘touchstart’, ( event ) => {
console.log(‘Tourched!’);
var xpos = event.getLocationX();
var ypos = event.getLocationY();
var aksi = cc.moveTo(0.2,xpos,ypos);
this.node.runAction(aksi);
console.log(xpos);
console.log(ypos);
While this is working for you, It might not work if you have more than one child attached to a parent node. Only last child which gets registered will work on touch. You are effectively replacing/overriding parents touchstart while instantiating your child node. This will also override any function bind to touchstart in parent script(If any). If you have multiple children or are planning for multiple children in future then consider moving above logic in parent node component script, locate each child by its id/name and move it accordingly.