Advertisement
snake5

psh animation state machine code

Mar 5th, 2017
441
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class PSHPlayerStateMachine
  2. {
  3.     global _char = "images/player_char";
  4.    
  5.     function _stand2run(c){ return abs( c.velocityX ) > 4; }
  6.    
  7.     function init(c)
  8.     {
  9.         return "stand";
  10.     }
  11.     function stand(c)
  12.     {
  13.         c.PlayAnim( "stand", true );
  14.        
  15.         if( this._stand2run(c) ) return "run";
  16.     }
  17.     function run(c)
  18.     {
  19.         c.PlayAnim( "run", true, 0, abs( c.velocityX ) / 200 );
  20.        
  21.         if( !this._stand2run(c) ) return "stand";
  22.     }
  23. }
  24.  
  25. class PSHPlayerCharacter : PSHCharacter
  26. {
  27.     global CharInfoAndStates = PSHPlayerStateMachine;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement