Hello EveryBody ,
I want to ask about adding sprites on touch … I’ve written this code the entire statements works outside the eventListener while it doesn’t inside it
var self = this;
cc.eventManager.addListener({
event : cc.EventListener.TOUCH_ONE_BY_ONE,
onTouchBegan: function(touch , event){
x = touch.getLocation().x;
y = touch.getLocation().y;
console.log(x ,y);
node = new cc.Node("New Sprite");
sprite = node.addComponent(cc.Sprite);
node.parent = this.node;
texture = cc.textureCache.addImage(url);
sprite.spriteFrame = new cc.SpriteFrame(texture);
node.setPosition(x,y);
return true;
},
},self.node);
},