Fix flickering bug by ensuring game canvas dimensions are even numbers in Phaser config

Abierto
#7,164 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 3 días

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
35/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
javascript

Línea de trabajo

No se nombra ningún archivo ni prueba del repositorio. Empieza por localizar la configuración del juego de Phaser que se muestra en el issue e inspecciona cómo se calculan las dimensiones de su canvas; se considerará terminado cuando las dimensiones impares o fraccionarias del viewport ya no produzcan parpadeos ni artefactos visuales durante el renderizado.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

A rendering flicker occurred when the Phaser game canvas width or height was an odd number. This issue was caused by subpixel rendering and rounding errors when the canvas size had fractional pixels. The solution was to adjust the game configuration to force both the width and height to be even numbers by subtracting 1 if they were odd. This ensures smoother rendering and prevents visual artifacts during gameplay.

If you want it more formal or detailed, just tell me!

     const config = {
            type: Phaser.AUTO,
            width: window.innerWidth % 2 === 1 ? window.innerWidth - 1 : window.innerWidth ,
            height: window.innerHeight % 2 === 1 ? window.innerHeight - 1 : window.innerHeight ,
           
            
            backgroundColor: '#2d2d2d',
            parent: gameRef.current,
            pixelArt: true,
            physics: {
                default: 'arcade',
                arcade: {
                    gravity: { y: 0 },
                    debug: false
                }
            },
            scene: [firstScene, ...Object.values(othersScenes)], // Aquí va el nombre de tu clase de escena

            // --- AÑADE ESTA SECCIÓN ---
            plugins: {
                global: [{
                    key: 'rexVirtualJoystick',
                    plugin: rexvirtualjoystickplugin, // El nombre de la clase del plugin
                    start: true
                }]
            }
        };

https://phaser.discourse.group/t/roundpixels-is-causing-jittering-with-cameras-main-startfollow/11880/8

I saw the solution in this post, I would like to know what is happening since my game is currently small and there should be no problems.

Lenguaje dominante
JavaScript
Estrellas
40.7k
Forks
7.2k
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de phaserjs/phaser

Todos los issues de phaserjs/phaser

Issues similares

Más issues de JavaScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.