proyecto26 / ion-phaser

A web component to use Phaser Framework with Angular, React, Vue, etc 🎮
https://market.ionicframework.com/plugins/ionphaser
MIT License
252 stars 39 forks source link

Scene changing not working #5

Closed r0m1n closed 5 years ago

r0m1n commented 5 years ago

Trying to change one scene from other. After executing

this.scene.start("OtherScene")

just have black screen without any errors. Any help?

  game = {
    width: 600,
    height: 600,
    type: Phaser.AUTO,
    scene: [OtherScene,FirstScene],
    physics: {
      default: 'arcade',
      arcade: {
        gravity: { y: 200 }
      }},
    instance: null
  }

 class FirstScene extends Phaser.Scene{

  constructor() {
    super({key: 'FirstScene'});
  }

  preload() {
...
  }

  create() {
....

    this.input.keyboard.on('keyup_S', ()=>{
      this.scene.start("OtherScene");
    }, this);

  }

class OtherScene extends Phaser.Scene{

  constructor(){
    super({key:'OtherScene'});

preload() {
console.log('OtherScene') //not working!!
...
  }
  }
jdnichollsc commented 5 years ago

@r0m1n what framework/library are you using? Angular, Vue or ReactJS?

jdnichollsc commented 5 years ago

Ok, I was able to reproduce this issue, it looks an issue from Phaser itself, after debugging different ways you can fix this by using a BootScene: https://github.com/proyecto26/ion-phaser/blob/master/demo-angular/src/app/app.component.ts#L52