Created
October 30, 2011 18:39
-
-
Save Nub/1326249 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| self.particles = [NSMutableArray array]; | |
| minimumLife = 3.0; | |
| maximumLife = 10.0; | |
| minimumParticles = 100; | |
| maximumParticles = 250; | |
| _deadParticles = (NSInteger*)malloc(sizeof(NSInteger) * maximumParticles); | |
| _deadParticleCount = maximumParticles; | |
| for (NSInteger i = 0; i < maximumParticles; i++) {//Cache all particles for speed | |
| _deadParticles[i] = i; | |
| ZParticle *particle = [[ZParticle alloc] init]; | |
| [self.particles addObject:particle]; | |
| [particle release]; | |
| } | |
| //used later in emit particles to snag an object to edit is properties | |
| - (ZParticle*)getDeadParticle{ | |
| NSInteger index = _deadParticles[--_deadParticleCount];//pull from the tail | |
| return [self.particles objectAtIndex:index]; | |
| } | |
| //used later in render object to setup rendering data and this is where the data is corrupt | |
| for (ZParticle *particle in self.particleEmitter.particles) { | |
| if ([particle isAlive]) { | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment