Quantcast
Channel: Cocos Forums - Latest topics
Viewing all articles
Browse latest Browse all 17083

How to make 100 Bunnies Hop while accessing a single animation action

$
0
0

@seraph7 wrote:

I am fairy new to Cocos2dx and I am trying to wrap my mind around how animations are performed. I am trying to optimize performance by having as little overhead as possible with an abstracted class.

Let's say I wanted to make 100 bunnies that have a hopping animation among other animations. I have a Bunny class and a MetaBunny class. The MetaBunny class would ideally perform as much of the animation preparation as possible so that all a bunny has to do is simply:

this->runAction(metaBunny->animations.hop);

where animations is a struct with member hop which returns something to the effect of:

RepeatForever::create(Animate::create(Animation::createWithSpriteFrames(animationFrames, animationSpeed)))

I've tried this and it seems that only 1 bunny can access the hopping at once. Strangely it hops much faster, as if the animations of all the bunnies are being channeled into the last bunny. Let's call it the super bunny. I've manually had some of the other bunnies perform other animations from the struct and the superbunny no longer has access to those animations. It seems that only 1 bunny can access the animation at once.

So I have a few questions from all of this:

  1. What portion of the animation process must I put in the instanced bunnies and what can (or ought) go in the metaBunny?
  2. Is my desire to house common variables in a metaClass object against best practices for Cocos2dx, or C++? If so, what should I be doing instead so that I maximize performance and abstraction in helpful ways?
  3. If each bunny must have its own set of variables (say animation frames) does this mean that the sprite sheet is loaded multiple times as well?
  4. I am not using TexturePacker, d you have any recommendations on resources to better understand how to work with animation frames and sprites in Cocos2dx? Most of what I have found seems outdated.

Thank you for your time looking at this. rabbit2

Posts: 2

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 17083

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>