Mode:
Duration:
1
Coding works best on desktop or with an external keyboard.
Coding works best on desktop or with an external keyboard.
A basic Phaser 3 program that creates a game with a moving sprite.
# phaser3/demo/index.html
<html>
<head>
<script src="https://cdn.jsdelivr.net/npm/phaser@3.60.0/dist/phaser.min.js"></script>
</head>
<body>
<script>
const config = {
type: Phaser.AUTO,
width: 800,
height: 600,
scene: {
preload: preload,
create: create,
update: update
}
};
const game = new Phaser.Game(config);
let player;
function preload() {
this.load.image('player', 'https://examples.phaser.io/assets/sprites/phaser-dude.png');
}
function create() {
player = this.add.sprite(400, 300, 'player');
}
function update() {
player.x += 1;
}
</script>
</body>
</html>Phaser 3 is a fast, open-source HTML5 game framework for creating 2D games for the web and mobile. It provides a complete ecosystem for rendering, physics, input, audio, and animation, allowing developers to build rich, interactive games in JavaScript or TypeScript.
Origin & Creator
Phaser was originally created by Richard Davey and maintained by Photon Storm, with Phaser 3 released in 2018 as the modern version of the framework.
Industrial Note
Phaser 3 is widely used for web-based games, educational games, interactive demos, gamified apps, and HTML5 advergames.