I am starting to use phaser to create games and I found a problem that I can not find for more tests that I did. I can not show the images I'm uploading. You only see a small square in the center, (I show it in this capture: when you should see the entire background of the canvas in green, which is the image that first charge. In the example I only charge one, so that more if it does not work. I do not see what error I'm committing, because the browser inspector does not show errors. The server is created with Node.js.
const http = require('http')
const fs = require('fs')
const server = http.createServer((req, res) => {
fs.readFile("./part1.html", (err, data) => {
if(err){console.error(err); return;}
res.end(data)
})
})
console.log('escuchando en el puerto 3000')
server.listen(3000)
I show the code for if someone can see the error I'm committing. Thanks.
var config = {
type: Phaser.AUTO,
width: 800,
height: 600,
scene: {
preload: preload,
create: create,
update: update
}
};
var game = new Phaser.Game(config);
function preload() {
this.load.image('sky', 'sky.png')
this.load.image('ground', 'platform.png')
this.load.image('star', 'star.png')
this.load.image('bomb', 'bomb.png')
this.load.spritesheet('dude', 'dude.png',{
frameWidth: 32, frameHeight: 48
});
}
function create() {
this.add.image(400, 300, 'sky')
}
function update() {
}
body {
margin: 0;
}
<!doctype html>
<html lang="es">
<head>
<meta charset="UTF-8" />
<title>Making your first Phaser 3 Game - Part 1</title>
<script src="//cdn.jsdelivr.net/npm/[email protected]/dist/phaser.js"></script>
</head>
<body>
</body>
</html>