Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

251
Views
How can user quit full screen in phaser.js?

I have a game that automatically plays in full screen with

this.scale.startFullscreen();

and i want to give a user an option to quit full screen by pressing 'x' in top right corner. So i wrote:

this.add.text(750, 20, 'X', { fontSize: '20px'});

this.exitFullScreen = this.add.rectangle(770, 30, 60, 60, 0xfff);

this.exitFullScreen.setInteractive();

this.exitFullScreen.on('pointerup', this.scale.stopfullScreen);

but that doesn't work, i also tried putting this.scale.stopfullScreen inside a callback function and i also added conditional if (isFullscreen()), but that didn't work either. Is there any way i can give user an option to quit full screen, ideally without removing this.scale.startFullscreen(); at the beginning of create()?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The problem is this line this.exitFullScreen.on('pointerup', this.scale.stopfullScreen); the eventlistener .on('pointerup', ...) calls the passed callback function with a different context.

Just change the eventlistener to .on('pointerup', () => this.scale.stopFullscreen()); and it should work.
Or you could pass the correct context (for the function) as third parameter to the eventlistener, like this: .on('pointerup', this.scale.stopFullscreen, this.scale);

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!