Skip to content

Commit

Permalink
Try to prevent canvas flicker on first render
Browse files Browse the repository at this point in the history
  • Loading branch information
hubol committed Dec 5, 2023
1 parent 873dd88 commit b775d56
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/igua/globals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ export const sceneStack = new IguaSceneStack(layers, (_scene) => scene = _scene)
export function installGlobals(_renderer: PixiRenderer) {
renderer = _renderer;

renderer.view.style.opacity = '0';

const displayCanvas = () => {
if (ticker.ticks >= 1) {
ticker.remove(displayCanvas);
renderer.view.style.opacity = '';
}
};

const ticker = new AsshatTicker();

KeyListener.start();
Expand All @@ -31,6 +40,8 @@ export function installGlobals(_renderer: PixiRenderer) {
Collision.recycleRectangles();
});

ticker.add(displayCanvas);

const animator = new Animator(60);
animator.start();

Expand Down
2 changes: 1 addition & 1 deletion src/lib/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ export const Environment = {
return window.location.href.includes('hwcdn');
},
get requiresUserGestureForSound() {
return true; // TODO
return Environment.isProduction && !Environment.isElectron;
}
};

0 comments on commit b775d56

Please sign in to comment.