Skip to content

Commit 44b076f

Browse files
committed
Particle now has a frame component
1 parent c7d08a3 commit 44b076f

1 file changed

Lines changed: 111 additions & 0 deletions

File tree

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
var Class = require('../../utils/Class');
2+
3+
var Particle = new Class({
4+
5+
initialize:
6+
7+
function Particle (x, y, frame)
8+
{
9+
// Phaser.Texture.Frame
10+
this.frame = frame;
11+
12+
this.index = 0;
13+
14+
this.x = x;
15+
this.y = y;
16+
17+
this.velocityX = 0;
18+
this.velocityY = 0;
19+
20+
this.scaleX = 1;
21+
this.scaleY = 1;
22+
23+
this.rotation = 0;
24+
25+
this.scrollFactorX = 1;
26+
this.scrollFactorY = 1;
27+
28+
this.color = 0xFFFFFFFF;
29+
30+
// Floats?
31+
this.life = 1;
32+
this.lifeStep = 1;
33+
this.normLifeStep = 1;
34+
35+
this.start = {
36+
tint: 0xFFFFFF,
37+
alpha: 1,
38+
scale: 1,
39+
angle: 0
40+
};
41+
42+
this.end = {
43+
tint: 0xFFFFFF,
44+
alpha: 1,
45+
scale: 1,
46+
angle: 0
47+
};
48+
},
49+
50+
reset: function (x, y, frame)
51+
{
52+
this.index = 0;
53+
54+
this.frame = frame;
55+
56+
this.x = x;
57+
this.y = y;
58+
59+
this.velocityX = 0;
60+
this.velocityY = 0;
61+
62+
this.scaleX = 1;
63+
this.scaleY = 1;
64+
65+
this.rotation = 0;
66+
67+
this.color = 0xFFFFFFFF;
68+
69+
this.life = 1;
70+
this.lifeStep = 1;
71+
this.normLifeStep = 1;
72+
73+
var start = this.start;
74+
75+
start.tint = 0xFFFFFF;
76+
start.alpha = 1;
77+
start.scale = 1;
78+
start.angle = 0;
79+
80+
var end = this.end;
81+
82+
end.tint = 0xFFFFFF;
83+
end.alpha = 1;
84+
end.scale = 1;
85+
end.angle = 0;
86+
87+
return this;
88+
},
89+
90+
isAlive: function ()
91+
{
92+
return (this.lifeStep > 0);
93+
},
94+
95+
/*
96+
setPosition: function (x, y)
97+
{
98+
this.x = x;
99+
this.y = y;
100+
},
101+
102+
setScale: function (x, y)
103+
{
104+
this.scaleX = x;
105+
this.scaleY = y;
106+
}
107+
*/
108+
109+
});
110+
111+
module.exports = Particle;

0 commit comments

Comments
 (0)