I am new to cocos creator. I am going through the examples in there.
There was an example scene called “Shooter” under collider folder.
It has following code…
bullet: {
default: null,
type: cc.Node
}
then …
cc.eventManager.addListener({
event: cc.EventListener.TOUCH_ONE_BY_ONE,
onTouchBegan: (touch, event) => {
var touchLoc = touch.getLocation();
var bullet = cc.instantiate(this.bullet);
bullet.position = touchLoc;
bullet.active = true;
bullet.zIndex = -1;
scene.addChild(bullet);
return true;
},
}, this.node);
Is it possible to instantiate a nun prefab like that?
What does => do?
When I changed it to function(touch, event) { …
It stopped working
Can anyone help?