Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

245
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda