Skip to content

Commit f0b6448

Browse files
author
Radu Angelescu
committed
fixed color interpolation for 2d particle systems
1 parent 411f98d commit f0b6448

1 file changed

Lines changed: 23 additions & 4 deletions

File tree

cocos/particle-2d/particle-simulator-2d.ts

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,32 @@ function getWorldRotation (node): number {
4747
}
4848
return rotation;
4949
}
50+
class ColorNumber {
51+
public r = 0;
52+
public g = 0;
53+
public b = 0;
54+
public a = 0;
55+
56+
constructor (r: number, g: number, b: number, a: number) {
57+
this.r = r;
58+
this.g = g;
59+
this.b = b;
60+
this.a = a;
61+
}
62+
63+
set (r: number, g: number, b: number, a: number): void {
64+
this.r = r;
65+
this.g = g;
66+
this.b = b;
67+
this.a = a;
68+
}
69+
}
5070

5171
class Particle {
5272
public pos = new Vec2(0, 0);
5373
public startPos = new Vec2(0, 0);
54-
public color = new Color(0, 0, 0, 255);
55-
public deltaColor = { r: 0, g: 0, b: 0, a: 255 };
74+
public color = new ColorNumber(0, 0, 0, 255);
75+
public deltaColor = new ColorNumber(0, 0, 0, 255);
5676
public size = 0;
5777
public deltaSize = 0;
5878
public rotation = 0;
@@ -81,8 +101,7 @@ const pool = new ParticlePool((par: Particle): void => {
81101
par.pos.set(Vec2.ZERO);
82102
par.startPos.set(Vec2.ZERO);
83103
par.color.set(0, 0, 0, 255);
84-
par.deltaColor.r = par.deltaColor.g = par.deltaColor.b = 0;
85-
par.deltaColor.a = 255;
104+
par.deltaColor.set(0, 0, 0, 255);
86105
par.size = 0;
87106
par.deltaSize = 0;
88107
par.rotation = 0;

0 commit comments

Comments
 (0)