melonJS
melonJS copied to clipboard
canvas is weirdly resized upon window resize
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 !"
}));
});