Jump to content
This forum will be closing down. Please move to the respective dedicated project forums.

Can't Move in New Scene


misnina
 Share

Recommended Posts

Sorry, I'm really new to this. I finally got different scenes working, but once I enter the second scene I can no longer move my character, and it's no longer reading the key outputs.
 The update for Level1 (the jump animation don't work but I'm not worried about that)
 

  update() {
     //KEYBOARD LISTENERS
    if (this.cursors.left.isDown)
    {
        this.player.setVelocityX(-160);
        this.player.anims.play('left', true);
    } else if (this.cursors.right.isDown)
    {
        this.player.setVelocityX(160);
        this.player.anims.play('right', true);
    } else
    {
        this.player.setVelocityX(0);
        this.player.anims.play('turn');
    }

    if (this.cursors.up.isDown) {
        this.player.anims.play('jump');
    }

    if (this.cursors.up.isDown && this.player.body.touching.down)
    {
        this.player.setVelocityY(-190);
    }
  }

The Changeover
 

function deathComplete (animation, frames) {
  game.scene.start('Level2', Level2, true);
  game.scene.remove('Level1');
}


the update for Level2
(the first console.log plays, but the left key one does not!)
 

 update() {

    console.log("Are you still listening?");
    //KEYBOARD LISTENERS
    if (this.cursors.left.isDown)
    {
        this.player.setVelocityX(-160);
        this.player.anims.play('left', true);
        console.log("I'm pressing left STILL");

    } else if (this.cursors.right.isDown)
    {
        this.player.setVelocityX(160);
        this.player.anims.play('right', true);
    } else
    {
        this.player.setVelocityX(0);
        this.player.anims.play('turn');
    }

    if (this.cursors.up.isDown) {
        this.player.anims.play('jump');
    }

    if (this.cursors.up.isDown && this.player.body.touching.down)
    {
        this.player.setVelocityY(-190);
    }
  }



Any help would be appreciated. I know I need working scenes for my  game, I must be missing something really simple.

sacrifice_scene.gif

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...