title: javascript phaser 3 animation
body: <p>I am trying to make an easy game in phaser 3. I have a player class which I call in create function of my gameScene.</p>
  <p>Player class :</p>
  <pre><code>class Player extends Phaser.Physics.Arcade.Sprite {
      constructor(scene, x, y, key, frame) {
  
          super(scene, x, y, key, frame);
          //the scene this game object will be added to
  
          this.scene = scene;
          //movement speed
          this.velocity = 500;
          //enable physics
          this.scene.physics.world.enable(this);
          //collisions with objects and player fix
          this.setImmovable(false);
          //bigger player
          this.setScale(2.5);
          //fix screen borders
          this.setCollideWorldBounds(true);
          //add player
          this.scene.add.existing(this);
  
          this.scene.cameras.main.startFollow(this);
  
  
          this.setVisible(true);
          // this.anims.create({
          //     key: 'walk-left',
          //     repeat: 0,
          //     frameRate: 10,
          //     frames: this.anims.generateFrameNames('playersoldier', {start: 3, end: 5})
          // });
  
  
  
  
      }
      update(cursors) {
          //controls
          if (cursors.left.isDown) {
              this.body.setVelocityX(-this.velocity);
              // this.walkLeft();
  
          } else if (cursors.right.isDown){
              this.body.setVelocityX(this.velocity);
          }
  
          if (cursors.up.isDown) {
              this.body.setVelocityY(-this.velocity);
          } else if (cursors.down.isDown){
              this.body.setVelocityY(this.velocity);
          }
      }
  
  //     walkLeft(){
  //         this.playersoldier = this.add.sprite(100, 100, 'playersoldier', 3);
  //         this.playersoldier.setScale(5);
  //         this.anims.create({
  //             key: 'walk-left',
  //             repeat: 0,
  //             frameRate: 10,
  //             frames: this.anims.generateFrameNames('playersoldier', {start: 3, end: 5})
  //         });
  //         this.playersoldier.play('walk-left', true);
  //     }
   }
  
  </code></pre>
  <p>These I call in mz create function in Gamescene file.</p>
  <pre><code>    createPlayer(){
          this.player = new Player(this, 500, 100, 'playersoldier');
      }
  
      createInput(){
          this.cursors = this.input.keyboard.createCursorKeys();
      }
  </code></pre>
  <p>I just cannot make it move :( there is some commented code, which is not working. And throwing out error that says, I cannot call .sprite etc. When I try animation separately. Without player and controls, it works fine.
  I just don't know how to implement it to Player Object.
  Any suggestions?
  I will be glad for any advice which will help.</p>
  <p>Thanks a lot for your time.</p>