Hello! Long time reader, first time poster.
I have a predefined set of coordinates which form a path stored in two NSMutableArrays (one containing the x values, one for the y values). There are roughly 40 sets of coordinates.
Below is the section of code I am currently using:
id patrolAction;
int pat_x1, pat_y1;
CCSequence *moveSequence;
for (int x = 0; x<[patrolPathX1 count]; x++){
pat_x1=[[patrolPathX1 objectAtIndex:x]intValue];
pat_y1=[[patrolPathY1 objectAtIndex:x]intValue];
patrolAction = [CCMoveTo actionWithDuration:1.5 position:[self positionForTileCoord:CGPointMake((float) pat_x1, (float) pat_y1)]];
moveSequence = [CCSequence actions:patrolAction, nil];
[enemy2 runAction:moveSequence];
}
The aim is to get the sprite (enemy2) to move along this predefined path, however the sprite is just moving across to the final set of coordinates straight away. When I take out the for loop and hardcode them individually, it works fine.
(When I put the "runAction" outside of the for loop, the same effect is produced)
I have tried putting in a CCDelayTime in the sequence, yet this doesn't seem to help.
Can anyone help me out with this issue?
Thanks in advance :)