melonJS icon indicating copy to clipboard operation
melonJS copied to clipboard

canvas is weirdly resized upon window resize

Open hornta opened this issue 8 months ago • 7 comments

The canvas is weirdly resized upon resizing the browser window. I noticed it when I alt+tabbed between my IDE and the browser, the canvas slowly get larger.

import { Text, device, game, video } from 'melonjs';

device.onReady(function () {
  // initialize the display canvas once the device/browser is ready
  if (!video.init(100, 30, {parent : "screen", scale : "auto"})) {
      alert("Your browser does not support HTML5 canvas.");
      return;
  }

  // set a gray background color
  game.world.backgroundColor.parseCSS("#202020");

  // add a font text display object
  game.world.addChild(new Text(609, 281, {
      font: "Arial",
      size: 160,
      fillStyle: "#FFFFFF",
      textBaseline : "middle",
      textAlign : "center",
      text : "Hello World !"
  }));
});

9db458ca-162c-47db-acd3-f766e4c1ddcc

hornta avatar Jun 22 '24 18:06 hornta