天天看點

CocosCreator案例學習_粒子系統

        針對CocosCreator自帶的案例學習一遍,俗話說,好記性不如爛筆頭,邊學習變記錄一下。

02節的粒子系統

cc.Class({
    extends: cc.Component,

    properties: {
        particle: cc.ParticleSystem,
    },

    toggleParticlePlay: function() {
        var myParticle = this.particle;
        if (myParticle.particleCount > 0) { // check if particle has fully plaed
            myParticle.stopSystem(); // stop particle system
        } else {
            myParticle.resetSystem(); // restart particle system
        }
    }
});
           

代碼裡通過toggleParticlePlay方法控制粒子停止播放或者恢複播放,myParticle.particleCount是目前播放的粒子數量,代碼通過這個目前播放的粒子數量是否大于判斷粒子是否播放中。

stopSystem()是停止發射器發射粒子; resetSystem()重新啟動粒子發射器發射粒子;

繼續閱讀