Jump to content

Phaser Button onInputOver Typescript not working


kikemx78
 Share

Recommended Posts

I can't fin a way to make this code work: 

namespace DeucesPhaser {

  export class ButFullScreen extends Phaser.Button {
    game: Phaser.Game;

    constructor(game: Phaser.Game, x: number, y: number) {

      super(game, x, y, 'butFullScreen');
      this.anchor.setTo(0.5);
      this.scale.setTo(0.8);
      this.game.add.existing(this);
      this.onInputOver.add(() => {
        this.goFullScreen();
      });

    }

    goFullScreen() {
      if (this.game.scale.isFullScreen) {
        this.game.scale.stopFullScreen();
      } else {
        this.game.scale.startFullScreen(false);
      }

    }
  }
}

goFullScreen() should be triggered by mouseOver but it only gets triggered with a click. Normally, onInputOver works fine on JS. Have no idea why I can't make this work on TypeScript.

Any help will be appreaciated..

Link to comment
Share on other sites

megmut I've already tried that with no success...

drhayes you're right, fullscreen needs a user event to work. Even thought, onInputOver (on Phaser & TypeScript) doesn't work as expected (like jQuery's hover) on no matter what kind of event. Look at this example: overS function is only triggered by click and not by mouseOver. The thing is, onInputOver works as jQuery's hover on PhaserJS but not on PhaserTScript.

 

create() {
      this.butStar2 = this.game.add.button(this.game.width * 0.2555, this.game.height * 0.32, 'butStar2');
      this.butStar2.onInputOver.add((e) => {
       this.overS(e);
      });
}

   overS(e) {
      if ( e.key === 'butStar2') {
        alert('yes');
      } else {
        alert('wtf');
      }

    }

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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