Issue
The following code consists of 2 parts: index.html
and game.js
.
var game = new Phaser.Game();
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title></title>
<script src="https://cdn.jsdelivr.net/npm/phaser@3.55.2/dist/phaser.js"></script>
</head>
<body>
<script type="text/javascript" src="game.js"></script>
</body>
</html>
The code above doesn't specify the width and height for the canvas though, when I inspected the page I got, I saw an extra line of HTML
<canvas width="1024" height="768"></canvas>
Who does put it in there? Does the browser, the web server or something else automatically add the extra line of HTML?
Solution
I would put my money on the script you're requesting in your header:
<script src="https://cdn.jsdelivr.net/npm/phaser@3.55.2/dist/phaser.js"></script>
That contains the code:
/***
@const {(number|string)} Phaser.Core.Config#width - The width of the underlying canvas, in pixels.
*/
this.width = GetValue(config, 'width', 1024);
/***
@const {(number|string)} Phaser.Core.Config#height - The height of the underlying canvas, in pixels.
*/
this.height = GetValue(config, 'height', 768);
So, to answer your question, it is the browser.
Answered By - mindthefrequency
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.