@luke2125 wrote:
Hi,
I'm trying to use the NodePool method to instantiate and destroy my bullets, but I'm having difficulty in the following code:
cc.Class({
extends: cc.Component,properties: { bulletreplinish:{ default: null, type: cc.Prefab }, }, // use this for initialization onLoad: function () {
this.bulletreplinishrandseconds = Math.floor((Math.random()*30)+15);
this.PutObjectBulletReplinish();
this.BulletReplinishRandomTimer();
this.myPool = new cc.NodePool('MyTemplateHandler');
},
BulletReplinishRandomTimer:function(){
this.schedule(this.GetObjectBulletReplinish,this.bulletreplinishrandseconds,cc.REPEAT_FOREVER, 1)},PutObjectBulletReplinish: function(){
let myNode = cc.instantiate(this.bulletreplinish);
this.myPool.put(myNode);
},
GetObjectBulletReplinish:function(){
let newNode = this.myPool.get();
}this.myPool = new cc.NodePool('MyTemplateHandler'); ????? This declares a new NodePool, but my TemplateHandler? Can someone just give me a brief explanation on how to use it for the above code? Really, would love to use NodePool for my objects to optimize game performance....Thanks and God Bless....
Sincerely,
Sunday
Posts: 2
Participants: 2