Jump to content

Transitional Animation


BrunoHautenfaust
 Share

Recommended Posts

To tell you the truth, the animation thing in this api kinda confuses me. I still can't quite figure out the difference between Animation Manager and Animation.
  I copied these in a notepad to ponder on:

 

A sprite can have a single Animation instance and an Animation Manager instance. 
The Animation Manager is used to add, play and update Phaser Animations.
The Animation instance contains a single animation and the controls to play it.
 
If the Animation Manager can take care of everything the animation can do, Why have the later(the animation) do it?
 
And I decided to try all the ways of playing animations both in create() and update() to see what's happening and why: http://phaser.io/sandbox/edit/pUliGpjo
 
So manager.play() works in create() because it's called once and the animation plays without interruption. That's clear.
manager.play() in update() perma-restars the animation because of the game loop(60 times per second update).
But then why does <sprite>.animations.play(<something>) work fine both in create() and update()?
Link to comment
Share on other sites

You're mixing both! <sprite>.animations IS the AnimationManager (even though the name is not really explicit). 

 

When you do myAnimation.play(), you're using the animation itself and asking it to play. This single animation has no knowledge of anything, like if an animation is currently playing.

If you do animations.play("myAnimation"), you're using the animationManager, and asking it to play the animation "myAnimation". It knows what's currently playing (as it manages all animations) and can check before starting an animation.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...