diff options
Diffstat (limited to 'libs/cocos2d/CCParticleExamples.m')
-rwxr-xr-x | libs/cocos2d/CCParticleExamples.m | 926 |
1 files changed, 926 insertions, 0 deletions
diff --git a/libs/cocos2d/CCParticleExamples.m b/libs/cocos2d/CCParticleExamples.m new file mode 100755 index 0000000..38c8b46 --- /dev/null +++ b/libs/cocos2d/CCParticleExamples.m | |||
@@ -0,0 +1,926 @@ | |||
1 | /* | ||
2 | * cocos2d for iPhone: http://www.cocos2d-iphone.org | ||
3 | * | ||
4 | * Copyright (c) 2008-2010 Ricardo Quesada | ||
5 | * Copyright (c) 2011 Zynga Inc. | ||
6 | * | ||
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy | ||
8 | * of this software and associated documentation files (the "Software"), to deal | ||
9 | * in the Software without restriction, including without limitation the rights | ||
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
11 | * copies of the Software, and to permit persons to whom the Software is | ||
12 | * furnished to do so, subject to the following conditions: | ||
13 | * | ||
14 | * The above copyright notice and this permission notice shall be included in | ||
15 | * all copies or substantial portions of the Software. | ||
16 | * | ||
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
23 | * THE SOFTWARE. | ||
24 | * | ||
25 | */ | ||
26 | |||
27 | |||
28 | // cocos2d | ||
29 | #import "CCParticleExamples.h" | ||
30 | #import "CCTextureCache.h" | ||
31 | #import "CCDirector.h" | ||
32 | #import "Support/CGPointExtension.h" | ||
33 | |||
34 | // | ||
35 | // ParticleFireworks | ||
36 | // | ||
37 | @implementation CCParticleFireworks | ||
38 | -(id) init | ||
39 | { | ||
40 | return [self initWithTotalParticles:1500]; | ||
41 | } | ||
42 | |||
43 | -(id) initWithTotalParticles:(NSUInteger)p | ||
44 | { | ||
45 | if( (self=[super initWithTotalParticles:p]) ) { | ||
46 | // duration | ||
47 | duration = kCCParticleDurationInfinity; | ||
48 | |||
49 | // Gravity Mode | ||
50 | self.emitterMode = kCCParticleModeGravity; | ||
51 | |||
52 | // Gravity Mode: gravity | ||
53 | self.gravity = ccp(0,-90); | ||
54 | |||
55 | // Gravity Mode: radial | ||
56 | self.radialAccel = 0; | ||
57 | self.radialAccelVar = 0; | ||
58 | |||
59 | // Gravity Mode: speed of particles | ||
60 | self.speed = 180; | ||
61 | self.speedVar = 50; | ||
62 | |||
63 | // emitter position | ||
64 | CGSize winSize = [[CCDirector sharedDirector] winSize]; | ||
65 | self.position = ccp(winSize.width/2, winSize.height/2); | ||
66 | |||
67 | // angle | ||
68 | angle = 90; | ||
69 | angleVar = 20; | ||
70 | |||
71 | // life of particles | ||
72 | life = 3.5f; | ||
73 | lifeVar = 1; | ||
74 | |||
75 | // emits per frame | ||
76 | emissionRate = totalParticles/life; | ||
77 | |||
78 | // color of particles | ||
79 | startColor.r = 0.5f; | ||
80 | startColor.g = 0.5f; | ||
81 | startColor.b = 0.5f; | ||
82 | startColor.a = 1.0f; | ||
83 | startColorVar.r = 0.5f; | ||
84 | startColorVar.g = 0.5f; | ||
85 | startColorVar.b = 0.5f; | ||
86 | startColorVar.a = 0.1f; | ||
87 | endColor.r = 0.1f; | ||
88 | endColor.g = 0.1f; | ||
89 | endColor.b = 0.1f; | ||
90 | endColor.a = 0.2f; | ||
91 | endColorVar.r = 0.1f; | ||
92 | endColorVar.g = 0.1f; | ||
93 | endColorVar.b = 0.1f; | ||
94 | endColorVar.a = 0.2f; | ||
95 | |||
96 | // size, in pixels | ||
97 | startSize = 8.0f; | ||
98 | startSizeVar = 2.0f; | ||
99 | endSize = kCCParticleStartSizeEqualToEndSize; | ||
100 | |||
101 | self.texture = [[CCTextureCache sharedTextureCache] addImage: @"fire.png"]; | ||
102 | |||
103 | // additive | ||
104 | self.blendAdditive = NO; | ||
105 | } | ||
106 | |||
107 | return self; | ||
108 | } | ||
109 | @end | ||
110 | |||
111 | // | ||
112 | // ParticleFire | ||
113 | // | ||
114 | @implementation CCParticleFire | ||
115 | -(id) init | ||
116 | { | ||
117 | return [self initWithTotalParticles:250]; | ||
118 | } | ||
119 | |||
120 | -(id) initWithTotalParticles:(NSUInteger) p | ||
121 | { | ||
122 | if( (self=[super initWithTotalParticles:p]) ) { | ||
123 | |||
124 | // duration | ||
125 | duration = kCCParticleDurationInfinity; | ||
126 | |||
127 | // Gravity Mode | ||
128 | self.emitterMode = kCCParticleModeGravity; | ||
129 | |||
130 | // Gravity Mode: gravity | ||
131 | self.gravity = ccp(0,0); | ||
132 | |||
133 | // Gravity Mode: radial acceleration | ||
134 | self.radialAccel = 0; | ||
135 | self.radialAccelVar = 0; | ||
136 | |||
137 | // Gravity Mode: speed of particles | ||
138 | self.speed = 60; | ||
139 | self.speedVar = 20; | ||
140 | |||
141 | // starting angle | ||
142 | angle = 90; | ||
143 | angleVar = 10; | ||
144 | |||
145 | // emitter position | ||
146 | CGSize winSize = [[CCDirector sharedDirector] winSize]; | ||
147 | self.position = ccp(winSize.width/2, 60); | ||
148 | posVar = ccp(40, 20); | ||
149 | |||
150 | // life of particles | ||
151 | life = 3; | ||
152 | lifeVar = 0.25f; | ||
153 | |||
154 | |||
155 | // size, in pixels | ||
156 | startSize = 54.0f; | ||
157 | startSizeVar = 10.0f; | ||
158 | endSize = kCCParticleStartSizeEqualToEndSize; | ||
159 | |||
160 | // emits per frame | ||
161 | emissionRate = totalParticles/life; | ||
162 | |||
163 | // color of particles | ||
164 | startColor.r = 0.76f; | ||
165 | startColor.g = 0.25f; | ||
166 | startColor.b = 0.12f; | ||
167 | startColor.a = 1.0f; | ||
168 | startColorVar.r = 0.0f; | ||
169 | startColorVar.g = 0.0f; | ||
170 | startColorVar.b = 0.0f; | ||
171 | startColorVar.a = 0.0f; | ||
172 | endColor.r = 0.0f; | ||
173 | endColor.g = 0.0f; | ||
174 | endColor.b = 0.0f; | ||
175 | endColor.a = 1.0f; | ||
176 | endColorVar.r = 0.0f; | ||
177 | endColorVar.g = 0.0f; | ||
178 | endColorVar.b = 0.0f; | ||
179 | endColorVar.a = 0.0f; | ||
180 | |||
181 | self.texture = [[CCTextureCache sharedTextureCache] addImage: @"fire.png"]; | ||
182 | |||
183 | // additive | ||
184 | self.blendAdditive = YES; | ||
185 | } | ||
186 | |||
187 | return self; | ||
188 | } | ||
189 | @end | ||
190 | |||
191 | // | ||
192 | // ParticleSun | ||
193 | // | ||
194 | @implementation CCParticleSun | ||
195 | -(id) init | ||
196 | { | ||
197 | return [self initWithTotalParticles:350]; | ||
198 | } | ||
199 | |||
200 | -(id) initWithTotalParticles:(NSUInteger) p | ||
201 | { | ||
202 | if( (self=[super initWithTotalParticles:p]) ) { | ||
203 | |||
204 | // additive | ||
205 | self.blendAdditive = YES; | ||
206 | |||
207 | // duration | ||
208 | duration = kCCParticleDurationInfinity; | ||
209 | |||
210 | // Gravity Mode | ||
211 | self.emitterMode = kCCParticleModeGravity; | ||
212 | |||
213 | // Gravity Mode: gravity | ||
214 | self.gravity = ccp(0,0); | ||
215 | |||
216 | // Gravity mode: radial acceleration | ||
217 | self.radialAccel = 0; | ||
218 | self.radialAccelVar = 0; | ||
219 | |||
220 | // Gravity mode: speed of particles | ||
221 | self.speed = 20; | ||
222 | self.speedVar = 5; | ||
223 | |||
224 | |||
225 | // angle | ||
226 | angle = 90; | ||
227 | angleVar = 360; | ||
228 | |||
229 | // emitter position | ||
230 | CGSize winSize = [[CCDirector sharedDirector] winSize]; | ||
231 | self.position = ccp(winSize.width/2, winSize.height/2); | ||
232 | posVar = CGPointZero; | ||
233 | |||
234 | // life of particles | ||
235 | life = 1; | ||
236 | lifeVar = 0.5f; | ||
237 | |||
238 | // size, in pixels | ||
239 | startSize = 30.0f; | ||
240 | startSizeVar = 10.0f; | ||
241 | endSize = kCCParticleStartSizeEqualToEndSize; | ||
242 | |||
243 | // emits per seconds | ||
244 | emissionRate = totalParticles/life; | ||
245 | |||
246 | // color of particles | ||
247 | startColor.r = 0.76f; | ||
248 | startColor.g = 0.25f; | ||
249 | startColor.b = 0.12f; | ||
250 | startColor.a = 1.0f; | ||
251 | startColorVar.r = 0.0f; | ||
252 | startColorVar.g = 0.0f; | ||
253 | startColorVar.b = 0.0f; | ||
254 | startColorVar.a = 0.0f; | ||
255 | endColor.r = 0.0f; | ||
256 | endColor.g = 0.0f; | ||
257 | endColor.b = 0.0f; | ||
258 | endColor.a = 1.0f; | ||
259 | endColorVar.r = 0.0f; | ||
260 | endColorVar.g = 0.0f; | ||
261 | endColorVar.b = 0.0f; | ||
262 | endColorVar.a = 0.0f; | ||
263 | |||
264 | self.texture = [[CCTextureCache sharedTextureCache] addImage: @"fire.png"]; | ||
265 | } | ||
266 | |||
267 | return self; | ||
268 | } | ||
269 | @end | ||
270 | |||
271 | // | ||
272 | // ParticleGalaxy | ||
273 | // | ||
274 | @implementation CCParticleGalaxy | ||
275 | -(id) init | ||
276 | { | ||
277 | return [self initWithTotalParticles:200]; | ||
278 | } | ||
279 | |||
280 | -(id) initWithTotalParticles:(NSUInteger)p | ||
281 | { | ||
282 | if( (self=[super initWithTotalParticles:p]) ) { | ||
283 | |||
284 | // duration | ||
285 | duration = kCCParticleDurationInfinity; | ||
286 | |||
287 | // Gravity Mode | ||
288 | self.emitterMode = kCCParticleModeGravity; | ||
289 | |||
290 | // Gravity Mode: gravity | ||
291 | self.gravity = ccp(0,0); | ||
292 | |||
293 | // Gravity Mode: speed of particles | ||
294 | self.speed = 60; | ||
295 | self.speedVar = 10; | ||
296 | |||
297 | // Gravity Mode: radial | ||
298 | self.radialAccel = -80; | ||
299 | self.radialAccelVar = 0; | ||
300 | |||
301 | // Gravity Mode: tagential | ||
302 | self.tangentialAccel = 80; | ||
303 | self.tangentialAccelVar = 0; | ||
304 | |||
305 | // angle | ||
306 | angle = 90; | ||
307 | angleVar = 360; | ||
308 | |||
309 | // emitter position | ||
310 | CGSize winSize = [[CCDirector sharedDirector] winSize]; | ||
311 | self.position = ccp(winSize.width/2, winSize.height/2); | ||
312 | posVar = CGPointZero; | ||
313 | |||
314 | // life of particles | ||
315 | life = 4; | ||
316 | lifeVar = 1; | ||
317 | |||
318 | // size, in pixels | ||
319 | startSize = 37.0f; | ||
320 | startSizeVar = 10.0f; | ||
321 | endSize = kCCParticleStartSizeEqualToEndSize; | ||
322 | |||
323 | // emits per second | ||
324 | emissionRate = totalParticles/life; | ||
325 | |||
326 | // color of particles | ||
327 | startColor.r = 0.12f; | ||
328 | startColor.g = 0.25f; | ||
329 | startColor.b = 0.76f; | ||
330 | startColor.a = 1.0f; | ||
331 | startColorVar.r = 0.0f; | ||
332 | startColorVar.g = 0.0f; | ||
333 | startColorVar.b = 0.0f; | ||
334 | startColorVar.a = 0.0f; | ||
335 | endColor.r = 0.0f; | ||
336 | endColor.g = 0.0f; | ||
337 | endColor.b = 0.0f; | ||
338 | endColor.a = 1.0f; | ||
339 | endColorVar.r = 0.0f; | ||
340 | endColorVar.g = 0.0f; | ||
341 | endColorVar.b = 0.0f; | ||
342 | endColorVar.a = 0.0f; | ||
343 | |||
344 | self.texture = [[CCTextureCache sharedTextureCache] addImage: @"fire.png"]; | ||
345 | |||
346 | // additive | ||
347 | self.blendAdditive = YES; | ||
348 | } | ||
349 | |||
350 | return self; | ||
351 | } | ||
352 | @end | ||
353 | |||
354 | // | ||
355 | // ParticleFlower | ||
356 | // | ||
357 | @implementation CCParticleFlower | ||
358 | -(id) init | ||
359 | { | ||
360 | return [self initWithTotalParticles:250]; | ||
361 | } | ||
362 | |||
363 | -(id) initWithTotalParticles:(NSUInteger) p | ||
364 | { | ||
365 | if( (self=[super initWithTotalParticles:p]) ) { | ||
366 | |||
367 | // duration | ||
368 | duration = kCCParticleDurationInfinity; | ||
369 | |||
370 | // Gravity Mode | ||
371 | self.emitterMode = kCCParticleModeGravity; | ||
372 | |||
373 | // Gravity Mode: gravity | ||
374 | self.gravity = ccp(0,0); | ||
375 | |||
376 | // Gravity Mode: speed of particles | ||
377 | self.speed = 80; | ||
378 | self.speedVar = 10; | ||
379 | |||
380 | // Gravity Mode: radial | ||
381 | self.radialAccel = -60; | ||
382 | self.radialAccelVar = 0; | ||
383 | |||
384 | // Gravity Mode: tagential | ||
385 | self.tangentialAccel = 15; | ||
386 | self.tangentialAccelVar = 0; | ||
387 | |||
388 | // angle | ||
389 | angle = 90; | ||
390 | angleVar = 360; | ||
391 | |||
392 | // emitter position | ||
393 | CGSize winSize = [[CCDirector sharedDirector] winSize]; | ||
394 | self.position = ccp(winSize.width/2, winSize.height/2); | ||
395 | posVar = CGPointZero; | ||
396 | |||
397 | // life of particles | ||
398 | life = 4; | ||
399 | lifeVar = 1; | ||
400 | |||
401 | // size, in pixels | ||
402 | startSize = 30.0f; | ||
403 | startSizeVar = 10.0f; | ||
404 | endSize = kCCParticleStartSizeEqualToEndSize; | ||
405 | |||
406 | // emits per second | ||
407 | emissionRate = totalParticles/life; | ||
408 | |||
409 | // color of particles | ||
410 | startColor.r = 0.50f; | ||
411 | startColor.g = 0.50f; | ||
412 | startColor.b = 0.50f; | ||
413 | startColor.a = 1.0f; | ||
414 | startColorVar.r = 0.5f; | ||
415 | startColorVar.g = 0.5f; | ||
416 | startColorVar.b = 0.5f; | ||
417 | startColorVar.a = 0.5f; | ||
418 | endColor.r = 0.0f; | ||
419 | endColor.g = 0.0f; | ||
420 | endColor.b = 0.0f; | ||
421 | endColor.a = 1.0f; | ||
422 | endColorVar.r = 0.0f; | ||
423 | endColorVar.g = 0.0f; | ||
424 | endColorVar.b = 0.0f; | ||
425 | endColorVar.a = 0.0f; | ||
426 | |||
427 | self.texture = [[CCTextureCache sharedTextureCache] addImage: @"fire.png"]; | ||
428 | |||
429 | // additive | ||
430 | self.blendAdditive = YES; | ||
431 | } | ||
432 | |||
433 | return self; | ||
434 | } | ||
435 | @end | ||
436 | |||
437 | // | ||
438 | // ParticleMeteor | ||
439 | // | ||
440 | @implementation CCParticleMeteor | ||
441 | -(id) init | ||
442 | { | ||
443 | return [self initWithTotalParticles:150]; | ||
444 | } | ||
445 | |||
446 | -(id) initWithTotalParticles:(NSUInteger) p | ||
447 | { | ||
448 | if( (self=[super initWithTotalParticles:p]) ) { | ||
449 | |||
450 | // duration | ||
451 | duration = kCCParticleDurationInfinity; | ||
452 | |||
453 | // Gravity Mode | ||
454 | self.emitterMode = kCCParticleModeGravity; | ||
455 | |||
456 | // Gravity Mode: gravity | ||
457 | self.gravity = ccp(-200,200); | ||
458 | |||
459 | // Gravity Mode: speed of particles | ||
460 | self.speed = 15; | ||
461 | self.speedVar = 5; | ||
462 | |||
463 | // Gravity Mode: radial | ||
464 | self.radialAccel = 0; | ||
465 | self.radialAccelVar = 0; | ||
466 | |||
467 | // Gravity Mode: tagential | ||
468 | self.tangentialAccel = 0; | ||
469 | self.tangentialAccelVar = 0; | ||
470 | |||
471 | // angle | ||
472 | angle = 90; | ||
473 | angleVar = 360; | ||
474 | |||
475 | // emitter position | ||
476 | CGSize winSize = [[CCDirector sharedDirector] winSize]; | ||
477 | self.position = ccp(winSize.width/2, winSize.height/2); | ||
478 | posVar = CGPointZero; | ||
479 | |||
480 | // life of particles | ||
481 | life = 2; | ||
482 | lifeVar = 1; | ||
483 | |||
484 | // size, in pixels | ||
485 | startSize = 60.0f; | ||
486 | startSizeVar = 10.0f; | ||
487 | endSize = kCCParticleStartSizeEqualToEndSize; | ||
488 | |||
489 | // emits per second | ||
490 | emissionRate = totalParticles/life; | ||
491 | |||
492 | // color of particles | ||
493 | startColor.r = 0.2f; | ||
494 | startColor.g = 0.4f; | ||
495 | startColor.b = 0.7f; | ||
496 | startColor.a = 1.0f; | ||
497 | startColorVar.r = 0.0f; | ||
498 | startColorVar.g = 0.0f; | ||
499 | startColorVar.b = 0.2f; | ||
500 | startColorVar.a = 0.1f; | ||
501 | endColor.r = 0.0f; | ||
502 | endColor.g = 0.0f; | ||
503 | endColor.b = 0.0f; | ||
504 | endColor.a = 1.0f; | ||
505 | endColorVar.r = 0.0f; | ||
506 | endColorVar.g = 0.0f; | ||
507 | endColorVar.b = 0.0f; | ||
508 | endColorVar.a = 0.0f; | ||
509 | |||
510 | self.texture = [[CCTextureCache sharedTextureCache] addImage: @"fire.png"]; | ||
511 | |||
512 | // additive | ||
513 | self.blendAdditive = YES; | ||
514 | } | ||
515 | |||
516 | return self; | ||
517 | } | ||
518 | @end | ||
519 | |||
520 | // | ||
521 | // ParticleSpiral | ||
522 | // | ||
523 | @implementation CCParticleSpiral | ||
524 | -(id) init | ||
525 | { | ||
526 | return [self initWithTotalParticles:500]; | ||
527 | } | ||
528 | |||
529 | -(id) initWithTotalParticles:(NSUInteger) p | ||
530 | { | ||
531 | if( (self=[super initWithTotalParticles:p]) ) { | ||
532 | |||
533 | // duration | ||
534 | duration = kCCParticleDurationInfinity; | ||
535 | |||
536 | // Gravity Mode | ||
537 | self.emitterMode = kCCParticleModeGravity; | ||
538 | |||
539 | // Gravity Mode: gravity | ||
540 | self.gravity = ccp(0,0); | ||
541 | |||
542 | // Gravity Mode: speed of particles | ||
543 | self.speed = 150; | ||
544 | self.speedVar = 0; | ||
545 | |||
546 | // Gravity Mode: radial | ||
547 | self.radialAccel = -380; | ||
548 | self.radialAccelVar = 0; | ||
549 | |||
550 | // Gravity Mode: tagential | ||
551 | self.tangentialAccel = 45; | ||
552 | self.tangentialAccelVar = 0; | ||
553 | |||
554 | // angle | ||
555 | angle = 90; | ||
556 | angleVar = 0; | ||
557 | |||
558 | // emitter position | ||
559 | CGSize winSize = [[CCDirector sharedDirector] winSize]; | ||
560 | self.position = ccp(winSize.width/2, winSize.height/2); | ||
561 | posVar = CGPointZero; | ||
562 | |||
563 | // life of particles | ||
564 | life = 12; | ||
565 | lifeVar = 0; | ||
566 | |||
567 | // size, in pixels | ||
568 | startSize = 20.0f; | ||
569 | startSizeVar = 0.0f; | ||
570 | endSize = kCCParticleStartSizeEqualToEndSize; | ||
571 | |||
572 | // emits per second | ||
573 | emissionRate = totalParticles/life; | ||
574 | |||
575 | // color of particles | ||
576 | startColor.r = 0.5f; | ||
577 | startColor.g = 0.5f; | ||
578 | startColor.b = 0.5f; | ||
579 | startColor.a = 1.0f; | ||
580 | startColorVar.r = 0.5f; | ||
581 | startColorVar.g = 0.5f; | ||
582 | startColorVar.b = 0.5f; | ||
583 | startColorVar.a = 0.0f; | ||
584 | endColor.r = 0.5f; | ||
585 | endColor.g = 0.5f; | ||
586 | endColor.b = 0.5f; | ||
587 | endColor.a = 1.0f; | ||
588 | endColorVar.r = 0.5f; | ||
589 | endColorVar.g = 0.5f; | ||
590 | endColorVar.b = 0.5f; | ||
591 | endColorVar.a = 0.0f; | ||
592 | |||
593 | self.texture = [[CCTextureCache sharedTextureCache] addImage: @"fire.png"]; | ||
594 | |||
595 | // additive | ||
596 | self.blendAdditive = NO; | ||
597 | } | ||
598 | |||
599 | return self; | ||
600 | } | ||
601 | @end | ||
602 | |||
603 | // | ||
604 | // ParticleExplosion | ||
605 | // | ||
606 | @implementation CCParticleExplosion | ||
607 | -(id) init | ||
608 | { | ||
609 | return [self initWithTotalParticles:700]; | ||
610 | } | ||
611 | |||
612 | -(id) initWithTotalParticles:(NSUInteger)p | ||
613 | { | ||
614 | if( (self=[super initWithTotalParticles:p]) ) { | ||
615 | |||
616 | // duration | ||
617 | duration = 0.1f; | ||
618 | |||
619 | self.emitterMode = kCCParticleModeGravity; | ||
620 | |||
621 | // Gravity Mode: gravity | ||
622 | self.gravity = ccp(0,0); | ||
623 | |||
624 | // Gravity Mode: speed of particles | ||
625 | self.speed = 70; | ||
626 | self.speedVar = 40; | ||
627 | |||
628 | // Gravity Mode: radial | ||
629 | self.radialAccel = 0; | ||
630 | self.radialAccelVar = 0; | ||
631 | |||
632 | // Gravity Mode: tagential | ||
633 | self.tangentialAccel = 0; | ||
634 | self.tangentialAccelVar = 0; | ||
635 | |||
636 | // angle | ||
637 | angle = 90; | ||
638 | angleVar = 360; | ||
639 | |||
640 | // emitter position | ||
641 | CGSize winSize = [[CCDirector sharedDirector] winSize]; | ||
642 | self.position = ccp(winSize.width/2, winSize.height/2); | ||
643 | posVar = CGPointZero; | ||
644 | |||
645 | // life of particles | ||
646 | life = 5.0f; | ||
647 | lifeVar = 2; | ||
648 | |||
649 | // size, in pixels | ||
650 | startSize = 15.0f; | ||
651 | startSizeVar = 10.0f; | ||
652 | endSize = kCCParticleStartSizeEqualToEndSize; | ||
653 | |||
654 | // emits per second | ||
655 | emissionRate = totalParticles/duration; | ||
656 | |||
657 | // color of particles | ||
658 | startColor.r = 0.7f; | ||
659 | startColor.g = 0.1f; | ||
660 | startColor.b = 0.2f; | ||
661 | startColor.a = 1.0f; | ||
662 | startColorVar.r = 0.5f; | ||
663 | startColorVar.g = 0.5f; | ||
664 | startColorVar.b = 0.5f; | ||
665 | startColorVar.a = 0.0f; | ||
666 | endColor.r = 0.5f; | ||
667 | endColor.g = 0.5f; | ||
668 | endColor.b = 0.5f; | ||
669 | endColor.a = 0.0f; | ||
670 | endColorVar.r = 0.5f; | ||
671 | endColorVar.g = 0.5f; | ||
672 | endColorVar.b = 0.5f; | ||
673 | endColorVar.a = 0.0f; | ||
674 | |||
675 | self.texture = [[CCTextureCache sharedTextureCache] addImage: @"fire.png"]; | ||
676 | |||
677 | // additive | ||
678 | self.blendAdditive = NO; | ||
679 | } | ||
680 | |||
681 | return self; | ||
682 | } | ||
683 | @end | ||
684 | |||
685 | // | ||
686 | // ParticleSmoke | ||
687 | // | ||
688 | @implementation CCParticleSmoke | ||
689 | -(id) init | ||
690 | { | ||
691 | return [self initWithTotalParticles:200]; | ||
692 | } | ||
693 | |||
694 | -(id) initWithTotalParticles:(NSUInteger) p | ||
695 | { | ||
696 | if( (self=[super initWithTotalParticles:p]) ) { | ||
697 | |||
698 | // duration | ||
699 | duration = kCCParticleDurationInfinity; | ||
700 | |||
701 | // Emitter mode: Gravity Mode | ||
702 | self.emitterMode = kCCParticleModeGravity; | ||
703 | |||
704 | // Gravity Mode: gravity | ||
705 | self.gravity = ccp(0,0); | ||
706 | |||
707 | // Gravity Mode: radial acceleration | ||
708 | self.radialAccel = 0; | ||
709 | self.radialAccelVar = 0; | ||
710 | |||
711 | // Gravity Mode: speed of particles | ||
712 | self.speed = 25; | ||
713 | self.speedVar = 10; | ||
714 | |||
715 | // angle | ||
716 | angle = 90; | ||
717 | angleVar = 5; | ||
718 | |||
719 | // emitter position | ||
720 | CGSize winSize = [[CCDirector sharedDirector] winSize]; | ||
721 | self.position = ccp(winSize.width/2, 0); | ||
722 | posVar = ccp(20, 0); | ||
723 | |||
724 | // life of particles | ||
725 | life = 4; | ||
726 | lifeVar = 1; | ||
727 | |||
728 | // size, in pixels | ||
729 | startSize = 60.0f; | ||
730 | startSizeVar = 10.0f; | ||
731 | endSize = kCCParticleStartSizeEqualToEndSize; | ||
732 | |||
733 | // emits per frame | ||
734 | emissionRate = totalParticles/life; | ||
735 | |||
736 | // color of particles | ||
737 | startColor.r = 0.8f; | ||
738 | startColor.g = 0.8f; | ||
739 | startColor.b = 0.8f; | ||
740 | startColor.a = 1.0f; | ||
741 | startColorVar.r = 0.02f; | ||
742 | startColorVar.g = 0.02f; | ||
743 | startColorVar.b = 0.02f; | ||
744 | startColorVar.a = 0.0f; | ||
745 | endColor.r = 0.0f; | ||
746 | endColor.g = 0.0f; | ||
747 | endColor.b = 0.0f; | ||
748 | endColor.a = 1.0f; | ||
749 | endColorVar.r = 0.0f; | ||
750 | endColorVar.g = 0.0f; | ||
751 | endColorVar.b = 0.0f; | ||
752 | endColorVar.a = 0.0f; | ||
753 | |||
754 | self.texture = [[CCTextureCache sharedTextureCache] addImage: @"fire.png"]; | ||
755 | |||
756 | // additive | ||
757 | self.blendAdditive = NO; | ||
758 | } | ||
759 | |||
760 | return self; | ||
761 | } | ||
762 | @end | ||
763 | |||
764 | @implementation CCParticleSnow | ||
765 | -(id) init | ||
766 | { | ||
767 | return [self initWithTotalParticles:700]; | ||
768 | } | ||
769 | |||
770 | -(id) initWithTotalParticles:(NSUInteger)p | ||
771 | { | ||
772 | if( (self=[super initWithTotalParticles:p]) ) { | ||
773 | |||
774 | // duration | ||
775 | duration = kCCParticleDurationInfinity; | ||
776 | |||
777 | // set gravity mode. | ||
778 | self.emitterMode = kCCParticleModeGravity; | ||
779 | |||
780 | // Gravity Mode: gravity | ||
781 | self.gravity = ccp(0,-1); | ||
782 | |||
783 | // Gravity Mode: speed of particles | ||
784 | self.speed = 5; | ||
785 | self.speedVar = 1; | ||
786 | |||
787 | // Gravity Mode: radial | ||
788 | self.radialAccel = 0; | ||
789 | self.radialAccelVar = 1; | ||
790 | |||
791 | // Gravity mode: tagential | ||
792 | self.tangentialAccel = 0; | ||
793 | self.tangentialAccelVar = 1; | ||
794 | |||
795 | // emitter position | ||
796 | self.position = (CGPoint) { | ||
797 | [[CCDirector sharedDirector] winSize].width / 2, | ||
798 | [[CCDirector sharedDirector] winSize].height + 10 | ||
799 | }; | ||
800 | posVar = ccp( [[CCDirector sharedDirector] winSize].width / 2, 0 ); | ||
801 | |||
802 | // angle | ||
803 | angle = -90; | ||
804 | angleVar = 5; | ||
805 | |||
806 | // life of particles | ||
807 | life = 45; | ||
808 | lifeVar = 15; | ||
809 | |||
810 | // size, in pixels | ||
811 | startSize = 10.0f; | ||
812 | startSizeVar = 5.0f; | ||
813 | endSize = kCCParticleStartSizeEqualToEndSize; | ||
814 | |||
815 | // emits per second | ||
816 | emissionRate = 10; | ||
817 | |||
818 | // color of particles | ||
819 | startColor.r = 1.0f; | ||
820 | startColor.g = 1.0f; | ||
821 | startColor.b = 1.0f; | ||
822 | startColor.a = 1.0f; | ||
823 | startColorVar.r = 0.0f; | ||
824 | startColorVar.g = 0.0f; | ||
825 | startColorVar.b = 0.0f; | ||
826 | startColorVar.a = 0.0f; | ||
827 | endColor.r = 1.0f; | ||
828 | endColor.g = 1.0f; | ||
829 | endColor.b = 1.0f; | ||
830 | endColor.a = 0.0f; | ||
831 | endColorVar.r = 0.0f; | ||
832 | endColorVar.g = 0.0f; | ||
833 | endColorVar.b = 0.0f; | ||
834 | endColorVar.a = 0.0f; | ||
835 | |||
836 | self.texture = [[CCTextureCache sharedTextureCache] addImage: @"fire.png"]; | ||
837 | |||
838 | // additive | ||
839 | self.blendAdditive = NO; | ||
840 | } | ||
841 | |||
842 | return self; | ||
843 | } | ||
844 | @end | ||
845 | |||
846 | @implementation CCParticleRain | ||
847 | -(id) init | ||
848 | { | ||
849 | return [self initWithTotalParticles:1000]; | ||
850 | } | ||
851 | |||
852 | -(id) initWithTotalParticles:(NSUInteger)p | ||
853 | { | ||
854 | if( (self=[super initWithTotalParticles:p]) ) { | ||
855 | |||
856 | // duration | ||
857 | duration = kCCParticleDurationInfinity; | ||
858 | |||
859 | self.emitterMode = kCCParticleModeGravity; | ||
860 | |||
861 | // Gravity Mode: gravity | ||
862 | self.gravity = ccp(10,-10); | ||
863 | |||
864 | // Gravity Mode: radial | ||
865 | self.radialAccel = 0; | ||
866 | self.radialAccelVar = 1; | ||
867 | |||
868 | // Gravity Mode: tagential | ||
869 | self.tangentialAccel = 0; | ||
870 | self.tangentialAccelVar = 1; | ||
871 | |||
872 | // Gravity Mode: speed of particles | ||
873 | self.speed = 130; | ||
874 | self.speedVar = 30; | ||
875 | |||
876 | // angle | ||
877 | angle = -90; | ||
878 | angleVar = 5; | ||
879 | |||
880 | |||
881 | // emitter position | ||
882 | self.position = (CGPoint) { | ||
883 | [[CCDirector sharedDirector] winSize].width / 2, | ||
884 | [[CCDirector sharedDirector] winSize].height | ||
885 | }; | ||
886 | posVar = ccp( [[CCDirector sharedDirector] winSize].width / 2, 0 ); | ||
887 | |||
888 | // life of particles | ||
889 | life = 4.5f; | ||
890 | lifeVar = 0; | ||
891 | |||
892 | // size, in pixels | ||
893 | startSize = 4.0f; | ||
894 | startSizeVar = 2.0f; | ||
895 | endSize = kCCParticleStartSizeEqualToEndSize; | ||
896 | |||
897 | // emits per second | ||
898 | emissionRate = 20; | ||
899 | |||
900 | // color of particles | ||
901 | startColor.r = 0.7f; | ||
902 | startColor.g = 0.8f; | ||
903 | startColor.b = 1.0f; | ||
904 | startColor.a = 1.0f; | ||
905 | startColorVar.r = 0.0f; | ||
906 | startColorVar.g = 0.0f; | ||
907 | startColorVar.b = 0.0f; | ||
908 | startColorVar.a = 0.0f; | ||
909 | endColor.r = 0.7f; | ||
910 | endColor.g = 0.8f; | ||
911 | endColor.b = 1.0f; | ||
912 | endColor.a = 0.5f; | ||
913 | endColorVar.r = 0.0f; | ||
914 | endColorVar.g = 0.0f; | ||
915 | endColorVar.b = 0.0f; | ||
916 | endColorVar.a = 0.0f; | ||
917 | |||
918 | self.texture = [[CCTextureCache sharedTextureCache] addImage: @"fire.png"]; | ||
919 | |||
920 | // additive | ||
921 | self.blendAdditive = NO; | ||
922 | } | ||
923 | |||
924 | return self; | ||
925 | } | ||
926 | @end | ||