2d对象池

2020-07-09  本文已影响0人  沉麟
getCoinPool() {
        if (this.coinPools.length <= 0) {
            let coin = new Laya.Image();
            coin.skin = "res/game/icon_jinbi.png";
            return coin;
        } else {
            return this.coinPools.pop();
        }
    }

    pushCoinPool(coin: Laya.Image) {
        this.coinPools.push(coin);
    }

    getLinePool() {
        if (this.linePools.length <= 0) {
            let coinAni = this.coinLineAni.clone();
            return coinAni;
        } else {
            return this.linePools.pop();
        }
    }

    pushLinePool(coinAni: Laya.Animation) {
        this.linePools.push(coinAni);
    }
上一篇 下一篇

猜你喜欢

热点阅读