美文网首页
Laya_2D示例项目使用对象池预制体的创建、位置设置和添加到父

Laya_2D示例项目使用对象池预制体的创建、位置设置和添加到父

作者: SeatonLv | 来源:发表于2019-05-28 16:04 被阅读0次

    //使用对象池创建盒子

    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);

    相关文章

      网友评论

          本文标题:Laya_2D示例项目使用对象池预制体的创建、位置设置和添加到父

          本文链接:https://www.haomeiwen.com/subject/oahhtctx.html