ulfben icon

Managing Animation State in GameObjects

ulfben | PRO | 01/26/16 10:44:55 AM UTC | 0 ⭐ | 10921 👁️ | Never ⏰ | []
ActionScript 3 |

0 B

|

None

|

0 👍

/

0 👎

/*
    This is an example of the simplest solution I can think off. 
    My question is: are there any good standard solutions / practices / patterns
        to deal with animation states? Especially as they get more complex than two states
        I imagine this solution being way too unwieldy to maintain.
 
 
    _idleAnimation and _turnAnimation are both members of the GameObject, 
        and children of its DisplayList.
*/
private function updateAnimationState(dx:Number):void
{
    if(Math.abs(dx) < 4)
    {
        start(_idleAnimation);
        stop(_turnAnimation);   
    }
    else 
    {
        stop(_idleAnimation);
        start(_turnAnimation);
        _turnAnimation.scaleX = (dx < 0) ? 1 : -1; //flip left/right
    } 
}
 
//EDIT: http://gamedev.stackexchange.com/questions/27079/data-driven-animation-states seems like a well researched comment

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  • Rteuixl icon
    04/02/26 04:33:18 PM UTC
    text |

    0 B

    |

    0 👍

    /

    0 👎

    Best t33n active cpx link daily updates!
     Copy and paste the link in a new browser tab and then hit enter!
     https://crazyporn.@xxx/members/157354/?asgtbndr=1&play=true&spon=adworld&zone=400
     Remove the @ 
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎