ulfben

Managing Animation State in GameObjects

Jan 26th, 2016
11,319
0
Never
4
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.     This is an example of the simplest solution I can think off.
  3.     My question is: are there any good standard solutions / practices / patterns
  4.         to deal with animation states? Especially as they get more complex than two states
  5.         I imagine this solution being way too unwieldy to maintain.
  6.  
  7.  
  8.     _idleAnimation and _turnAnimation are both members of the GameObject,
  9.         and children of its DisplayList.
  10. */
  11. private function updateAnimationState(dx:Number):void
  12. {
  13.     if(Math.abs(dx) < 4)
  14.     {
  15.         start(_idleAnimation);
  16.         stop(_turnAnimation);  
  17.     }
  18.     else
  19.     {
  20.         stop(_idleAnimation);
  21.         start(_turnAnimation);
  22.         _turnAnimation.scaleX = (dx < 0) ? 1 : -1; //flip left/right
  23.     }
  24. }
  25.  
  26. //EDIT: http://gamedev.stackexchange.com/questions/27079/data-driven-animation-states seems like a well researched comment
Advertisement
Comments
  • User was banned
  • Rteuixl
    217 days
    # text 0.21 KB | 0 0
    1. Best t33n active cpx link daily updates!
    2.  
    3. Copy and paste the link in a new browser tab and then hit enter!
    4.  
    5. https://crazyporn.@xxx/members/157354/?asgtbndr=1&play=true&spon=adworld&zone=400
    6.  
    7. Remove the @
  • User was banned
  • Comment was deleted
Add Comment
Please, Sign In to add comment