I want to create an action once, then add it to multiple sprites. For example, I have a 'monster' that gets a bunch of legs added to its body. Each of these legs are children of the body, and I want them to rotate back and forth. I made a CCRepeatForever
of a sequence of two CCRotateBy
actions which works great. I can add the action to a leg, but if I then add it to a different leg, the first leg doesn't rotate.
I don't want to make a new sequence for each leg - what a pain! There's gotta be an easy way!
EDIT:
I implemented it like this, per gixdev and Lukman's answers... (thanks AGAIN Lukman!)
[leg1 runAction:action]; // for the first time using the action
[leg2 runAction:[[action copy] autorelease]]; // for all subsequent uses
If copy your once created actions it help you
[leg1 runAction:[action copy]];
[leg2 runAction:[action copy]];
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With