Hi all,
All of my characters movement actions are wrapped in a Speed action so that I can modify the speed of the action on the fly. I understand that reusing actions is much faster that alloc'ing them every time they are needed, and I think that have this working with all of my RotateTo, MoveTo, and CallFunc actions, but I am a bit stuck getting this to work with the Speed action that contains my action sequence.
So on init of my character, I create the actions that I will be needing:
charRotation = [[RotateTo actionWithDuration: 0 angle: 0] retain];
charMoveTo = [[MoveTo actionWithDuration: 0 position: ccp(0, 0)] retain];
callbackFn = [[CallFunc actionWithTarget: self selector: @selector(updateIntentions:)] retain];
charSpeedAction = [[Speed action] retain];
Then, when I need to update the characters movement / direction of travel, I do:
[self runAction: [charSpeedAction initWithAction: [Sequence actions: [charMoveTo initWithDuration: movementDuration position: positionToMoveTo], callbackFn, nil] speed: moveSpeed]];
This works the first time it gets called, but on the second time, the app quits and I get this error:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Action already running'
Any ideas what I might be doing wrong? Thanks in advance,
Mike