//使用对象池创建盒子
1.对象池的使用
对象池创建箱子
let box = Laya.Pool.getItemByCreateFun("dropBox", this.dropBox.create, this.dropBox);
2.设置位置
box.pos(Math.random() * (Laya.stage.width - 100), -100);
3.添加父节点
this._gameBox.addChild(box);
//使用对象池创建盒子
对象池创建箱子
let box = Laya.Pool.getItemByCreateFun("dropBox", this.dropBox.create, this.dropBox);
box.pos(Math.random() * (Laya.stage.width - 100), -100);
this._gameBox.addChild(box);
本文标题:Laya_2D示例项目使用对象池预制体的创建、位置设置和添加到父
本文链接:https://www.haomeiwen.com/subject/oahhtctx.html
网友评论