Spawn of Animation

Up until now I have had animations for the following:

  1.     Default ,
  2.     Dying
  3.     Dead 
  4.     Flying 
  5.     Spitting 
  6.     Eating 
  7.     Farting 
  8.     Pooping

and I decided to create another for Spawning.

I don’t use cocos2d-x own Animation classes – I use  my own, because, honestly, I didn’t think the cocos2d-x animation classes gave me enough control when I first looked at them; subsequently I think maybe they do, but I have my own class which is nicely flexible!

Adding a new type is a simple matter of adding an entry to a pList, together with a string representation – so I added spawning with string “Spawning”

Now I can call Animation::startAnimation(enum::Spawning) and it looks for an animation XXXXSpawning in the collection of animations for that particular Visible Object (another of my classes).

Encountered a couple of issues.

Firstly, if you die while farting(!) I needed to stop the farting animation; I’d just used showAnimation(enum::Default);

And in my reset function I call StopFarting();

So, at the start of a level, it showed the default animation instead of the spawning animation. easily fixed.

The other problem was with jumping. I have a flying animation shown when Poopy jumps. so when he lands, detected using a sensor, I changed the animation to default. Of course, this also stuffed up the spawning animation, as during spawning, Poopy would land, and the spawning animation would stop.

Again, not a difficult fix.

Now all I have to do is actually design a spawning animation! (for testing I used the dying animation, shown backward.)

These changes also gave me a new method, continuePreviousAnimation()

so now, if I am in the middle of one animation, and go off to do something else, instead of reverting back to the default animation, I can continue with the one I was showing before.

 

Leave a Reply

Your email address will not be published. Required fields are marked *