Hello, I have a, I think, simple issue. I’m trying to get a childNode by using it’s tag. I have a function that is called several times:
if(!this.hasPath) return;
if(this.positionOnPath==1){
var drawPrefab = cc.instantiate(this.drawPathNode);
drawPrefab.getComponent('scr_drawPath').setPath(this.pathToTarget);
drawPrefab.getComponent('scr_drawPath').draw(this.positionOnPath);
this.node.addChild(drawPrefab,111);
return;
}
var drawPrefab = this.node.getChildByTag(111);
drawPrefab.getComponent('scr_drawPath').draw(this.positionOnPath);
As you can see, I create a childNode when the function is called and the ‘positionOnPath’ variable is set to ‘1’. The position get incremented elsewhere then the function is called again. I am wanting something different to happen when the position is not ‘1’ and I’m trying to update the childNode I created previously but I am unable to reference it. This is why I’m trying to use the getChildByTag feature.
Is there something obvious that I am doing wrong here?
Thanks in advance!
Sam