Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class Player extends AnimatedEntity {
  2.  constructor(){
  3.     this.movementMachine = new MovementStepMachine();
  4.  
  5.     let animationIdle = new Animation(spriteSheet, speed = speedPlayer);
  6.  
  7.     ...
  8.  
  9.     this.movementStateAnimations = {
  10.         [ MovementState.Idle, animationIdle ],
  11.         [ MovementState.WalkRight, animationWalkRight ],
  12.         [ MovementState.WalkLeft, animationWalkLeft ],
  13.     };
  14.  }
  15.  
  16.  //Override
  17.  update(dt){
  18.     //Procesamos todo el movimiento y cambio de estado.
  19.     this.movementMachine.updateMovement();
  20.     this.movementMachine.updateState();
  21.  
  22.     //CurrentAnimation es parte de AnimatedEntity (deberia... no?)
  23.     this.currentAnimation = this.movementStateAnimations[this.movementMachine.MovementState];
  24.    
  25.     //Seteando el currentAnimation y luego llamando al update de la AnimatedEntity (super == parent == clase base)
  26.     //Se anima con la animacion actual
  27.     super.update(dt);
  28.  }
  29.  
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement