Hi guys, I have some noob questions.
I create the new objects within an event. I don’t know if the events happen in a different thread or it is a call inside the game loop. For example, if I’ve to create a shot/blast I do:
onKeyDown (event: cc.Event.EventKeyboard) {
switch (event.keyCode) {
...
case cc.macro.KEY.space:
this.onShot();
break;
}
}
onShot() : void {
let shotNode: cc.Node = cc.instantiate (this.shotPrefab);
cc.Canvas.instance.node.getChildByName ('Shots').addChild (shotNode); // Agrega al prefab dentro del Node
shotNode.x = this.node.x;
shotNode.y = this.node.getBoundingBox().yMax;
this.shoots.push (shotNode);
}
My questions:
- Allocation in game loop?
- Is there a special thread to create or delete objects?
- Events happen in a different thread or it’s called from the game loop?
- if events are in different thread, is it thread safe?
Thanks