plawres
plawres

Reputation: 313

Reuse cocos2d actions

Is it possible (and a good practice) to reuse the same actions for multiple CCSprites that use the same action?

For if I have 10 CCSprites that all need to be scaled. And I create a scale action called scaleAction. Is it possible to reuse the same action for a sprites?

When I tried to do that I get only one sprite scaling and not all of them. What's the best way to do this?

Thanks in advance

Upvotes: 2

Views: 644

Answers (2)

CodeSmile
CodeSmile

Reputation: 64478

Since the question asks about re-using one action for multiple sprites, the answer is a clear: no.

Each sprite must run its own actions. If there's an action that's already running on node A and you're trying to run the same action on node B, the action will only affect one of the two nodes.

Upvotes: 1

Sebastián Castro
Sebastián Castro

Reputation: 1408

As far as i know is not recommended to reuse actions. You should check the following links about the same issue that you have and how they solve the issue. Best way in my opinion is go to a subclass approach.

retain CCActions for best performance

Cocos2D: Reuse animation for different sprites

BTW, a simple search on our friend google answer you question :)

Upvotes: 1

Related Questions