So i have a big thing that i want to implement and I need to do it soon. I would really appreciate some help from the community as i cannot get it play back fluidly.
basically i am trying to record a particle as it moves (as it is user controlled) and "record" the movement to play back. Would you be willing to give me a hand with this? I have some basic code down but it doesn't work fluidly. I would like to get this done this weekend if I can and would be willing to give you $50 (not a lot i know, can give you more once it goes on sale as i have no $$ right now) to help me in such short notice. I want to be able to record up to 5 or 10 different particles.
for informational purposes of the variables
theParticles is a NSMutableArray
particle1X and particle1Y are arrays of int
i call it like this when i want to start recording
[self schedule:@selector(createParticlePositionArrays:) interval:1/20.0];
which calls this function
- (void)createParticlePositionArrays:(ccTime) dt {
for (CCParticleSystemQuad *particleZ in theParticles) {
particle1X[currentArrayIndex] = particleZ.position.x;
particle1Y[currentArrayIndex] = particleZ.position.y;
currentArrayIndex++;
if (currentArrayIndex == 100) {
[self unschedule:@selector(createParticlePositionArrays:)];
ParticleActions = 0;
doingParticleAction = 0;
currentArrayIndex = 0;
CCParticleSystemQuad *particle1;
particle1 = [CCParticleSystemQuad particleWithFile:@"fire.plist"];
particle1.position = ccp(particle1X[0], particle1Y[0]);
particle1.tag = 101;
[self addChild:particle1];
[self schedule:@selector(MoveSavedParticles:) interval:1/20.0];
}
return;
}
}
and i play it back with this
- (void)MoveSavedParticles:(ccTime) dt {
CCArray *theChildren = self.children;
CCParticleSystemQuad* node;
CCARRAY_FOREACH(theChildren, node)
{
if (node.tag == 101) {
[node runAction:[CCMoveTo actionWithDuration:1/20.0 position:ccp(particle1X[particle1ArraySavedIndex], particle1Y[particle1ArraySavedIndex])]];
particle1ArraySavedIndex++;
if (particle1X[particle1ArraySavedIndex] == 0) {
particle1ArraySavedIndex = 0;
[node runAction:[CCMoveTo actionWithDuration:0 position:ccp(particle1X[particle1ArraySavedIndex], particle1Y[particle1ArraySavedIndex])]];
}
return;
}
}
}
if possible i would also like to make it where it records multiple particles at once. but the main part is getting the recording and playback to be fluid, then i can deal with the rest probably :)