-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathTSParticleSystemQuad.m
More file actions
61 lines (53 loc) · 1.81 KB
/
TSParticleSystemQuad.m
File metadata and controls
61 lines (53 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#import "TSParticleSystemQuad.h"
@implementation TSParticleSystemQuad
-(id) initWithDictionary:(NSDictionary *)dictionary
{
if ((self = [super initWithDictionary:dictionary])) {
// fix the emission rate
if ([dictionary objectForKey:@"emissionRate"]) {
float value = [[dictionary objectForKey:@"emissionRate"] floatValue];
if (value > 0.0) {
emissionRate = value;
}
}
// if end color is disabled, set it to the beginning color
m_endColorEnabled = YES;
if ([dictionary objectForKey:@"finishColorEnabled"]) {
BOOL value = [[dictionary objectForKey:@"finishColorEnabled"] boolValue];
m_endColorEnabled = value;
if (value == NO) {
endColor = startColor;
endColorVar = startColorVar;
}
}
// if all particles are the same color, just save the flag
m_colorSet = NO;
m_allParticlesSameColor = NO;
if ([dictionary objectForKey:@"allParticlesSameColor"]) {
BOOL value = [[dictionary objectForKey:@"allParticlesSameColor"] boolValue];
m_allParticlesSameColor = value;
}
}
return self;
}
-(void) initParticle:(tCCParticle *)particle
{
[super initParticle:particle];
if (m_endColorEnabled == NO) {
particle->deltaColor.r = 0;
particle->deltaColor.g = 0;
particle->deltaColor.b = 0;
}
if (m_allParticlesSameColor) {
if (m_colorSet) {
particle->color = m_particleColor;
particle->deltaColor = m_particleDeltaColor;
}
else {
m_colorSet = YES;
m_particleColor = particle->color;
m_particleDeltaColor = particle->deltaColor;
}
}
}
@end