kikemx78 Posted June 18, 2016 Share Posted June 18, 2016 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 More sharing options...
kikemx78 Posted June 19, 2016 Author Share Posted June 19, 2016 @photonstorm is the above post a bug?? Link to comment Share on other sites More sharing options...
megmut Posted June 20, 2016 Share Posted June 20, 2016 I don't usually use phaser buttons, but I'm pretty sure all input relation functions are placed inside the events object. You're code, I suspect, may be 'this.events.onInputDown.add(() => {...}; http://phaser.io/docs/2.4.4/Phaser.Button.html#events Hope this helps! Link to comment Share on other sites More sharing options...
drhayes Posted June 20, 2016 Share Posted June 20, 2016 You can only go full screen in response to a user event like a click. There's no way to do it via hover. This is a browser security measure and can't be overridden from within Phaser (or JS at all). Link to comment Share on other sites More sharing options...
kikemx78 Posted June 21, 2016 Author Share Posted June 21, 2016 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 More sharing options...
drhayes Posted June 21, 2016 Share Posted June 21, 2016 You're saying that your overS function isn't being called when you hover the button? Link to comment Share on other sites More sharing options...
kikemx78 Posted June 21, 2016 Author Share Posted June 21, 2016 yes...function is not being called by hover event.... Link to comment Share on other sites More sharing options...
Recommended Posts