diff --git a/cocos2d/particle/CCParticleSystem.js b/cocos2d/particle/CCParticleSystem.js index ff6760792d..444c071d69 100644 --- a/cocos2d/particle/CCParticleSystem.js +++ b/cocos2d/particle/CCParticleSystem.js @@ -921,16 +921,17 @@ var ParticleSystem = cc.Class({ } self._plistFile = file.nativeUrl; - if (self._custom) { - self._initTextureWithDictionary(content); + if (!self.spriteFrame) { + if (file.texture) { + self.spriteFrame = new cc.SpriteFrame(file.texture); + } + else { + self._initTextureWithDictionary(content); + } } - else { + if (!self._custom) { self._initWithDictionary(content); } - - if (file.texture) { - self.spriteFrame = new cc.SpriteFrame(file.texture); - } }); } }, @@ -1094,10 +1095,7 @@ var ParticleSystem = cc.Class({ _onTextureLoaded: function (event) { this._texture = this._spriteFrame.getTexture(); - // Mark render data dirty - if (this._renderData) { - this._renderData.uvDirty = true; - } + this._simulator.updateUVs(true); // Reactivate material this._activateMaterial(); }, diff --git a/cocos2d/particle/particle-simulator.js b/cocos2d/particle/particle-simulator.js index fc69d9fc65..4e26cf1a45 100644 --- a/cocos2d/particle/particle-simulator.js +++ b/cocos2d/particle/particle-simulator.js @@ -191,13 +191,15 @@ Simulator.prototype.emitParticle = function (pos) { } }; -Simulator.prototype.updateUVs = function (particleCount) { +Simulator.prototype.updateUVs = function (force) { + let particleCount = this.particles.length; if (this.sys._buffer && this.sys._spriteFrame) { const FLOAT_PER_PARTICLE = 4 * this.sys._vertexFormat._bytes / 4; let vbuf = this.sys._buffer._vData; let uv = this.sys._spriteFrame.uv; - for (let i = this._uvFilled; i < particleCount; i++) { + let start = force ? 0 : this._uvFilled; + for (let i = start; i < particleCount; i++) { let offset = i * FLOAT_PER_PARTICLE; vbuf[offset+2] = uv[0]; vbuf[offset+3] = uv[1]; @@ -303,7 +305,7 @@ Simulator.prototype.step = function (dt) { // Fill up uvs if (particleCount > this._uvFilled) { - this.updateUVs(particleCount); + this.updateUVs(); } // Used to reduce memory allocation / creation within the loop