ウィンドウサイズを取得するのに問題があります。次のコードを試します。
Javascript
var game;
function game() {
this.canvas = document.getElementById('canvas');
this.canvasWidth = window.innerWidth;
this.canvasHeight = window.innerHeight;
this.initCanvas = function() {
this.canvas.style.width = this.canvasWidth + "px";
this.canvas.style.height = this.canvasHeight + "px";
}
this.run = function() {
this.initCanvas();
}
}
game = new game();
game.run();
私も持っています
CSS
html, body {
padding: 0;
margin: 0;
}
私の体にはキャンバスしかありません。
問題は、垂直と水平のスクロール バーがあることです。これは、キャンバスのサイズが大きすぎることを意味します。スクロールバーが表示されないウィンドウサイズにする方法は?