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

Aperta
#7,164 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 3 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
javascript

Direzione di ricerca

Non viene indicato alcun file o test del repository. Inizia individuando la configurazione del gioco Phaser mostrata nell’issue e analizza come vengono calcolate le dimensioni del canvas; il lavoro è completato quando dimensioni dispari o frazionarie del viewport non producono più sfarfallio o artefatti visivi durante il rendering.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
JavaScript
Stelle
40.7k
Fork
7.2k
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di phaserjs/phaser

Tutte le issue di phaserjs/phaser

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.