Skip to content

Commit 192a305

Browse files
authored
ParticleSystem: Mark as ChangeColor only if needed
This avoid a waste of resources (particle image redraw), if the delta is only the alpha, which is handled by the context's globalAlpha
1 parent 2083141 commit 192a305

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

Diff for: cocos2d/particle/CCParticleSystemCanvasRenderCmd.js

+6-5
Original file line numberDiff line numberDiff line change
@@ -195,11 +195,12 @@
195195
};
196196
proto._updateDeltaColor = function (selParticle, dt) {
197197
if (!this._node._dontTint) {
198-
selParticle.color.r += selParticle.deltaColor.r * dt;
199-
selParticle.color.g += selParticle.deltaColor.g * dt;
200-
selParticle.color.b += selParticle.deltaColor.b * dt;
201-
selParticle.color.a += selParticle.deltaColor.a * dt;
202-
selParticle.isChangeColor = true;
198+
var deltaColor = selParticle.deltaColor;
199+
selParticle.color.r += deltaColor.r * dt;
200+
selParticle.color.g += deltaColor.g * dt;
201+
selParticle.color.b += deltaColor.b * dt;
202+
selParticle.color.a += deltaColor.a * dt;
203+
selParticle.isChangeColor = deltaColor.r !== 0 || deltaColor.g !== 0 || deltaColor.b !== 0;
203204
}
204205
};
205206
})();

0 commit comments

Comments
 (0)