In the rhythm app I'm creating, I've set up a single particle emitter for each key that's played correctly.
Here's the code that triggers this:
-(void) enableEmitterForNoteValue:(int)noteValue WithPercentage:(double)percentage {
int index = noteValue - 36;
SKEmitterNode *emitter = [_emitters objectAtIndex:index];
emitter.particleColorSequence = nil;
emitter.particleColorBlendFactor = 1.0;
if (percentage == kNotePerfectHitPercentage)
[emitter setParticleColor:[NSColor whiteColor]];
else if (percentage == kNoteOkayHitPercentage || percentage == kNoteEarlyHitPercentage)
[emitter setParticleColor:[NSColor yellowColor]];
else if (percentage == kNoteLateHitPercentage)
[emitter setParticleColor:[NSColor orangeColor]];
[emitter resetSimulation];
[emitter setParticleBirthRate:200];
}
Problem: When notes at the same pitch (played with the same key) occur in rapid succession, the particles that are emitted are reset because I'm called resetSimulation:
. If I don't call resetSimulation:
, then the particles will only show up once. Is there a way to get around this? Here's an example of notes that come in quick succession below.