Platformer Jump Example - Phaser Typing CST Test
Loading…
Platformer Jump Example — Phaser Code
Simple Phaser platformer setup where a player can jump using physics.
import Phaser from 'phaser';
class PlatformScene extends Phaser.Scene {
preload() {
this.load.image('player', 'assets/player.png');
this.load.image('ground', 'assets/platform.png');
}
create() {
this.physics.add.staticImage(400, 580, 'ground').setScale(2).refreshBody();
this.player = this.physics.add.sprite(400, 450, 'player');
this.player.setBounce(0.2);
this.physics.add.collider(this.player, this.physics.world.staticBodies);
this.cursors = this.input.keyboard.createCursorKeys();
}
update() {
if(this.cursors.up.isDown && this.player.body.touching.down) {
this.player.setVelocityY(-330);
}
}
}
new Phaser.Game({ type: Phaser.AUTO, width: 800, height: 600, physics: { default: 'arcade', arcade: { gravity: { y: 300 } } }, scene: [PlatformScene] });Phaser Language Guide
Phaser is a fast, open-source 2D HTML5 game framework used to create browser-based games for desktop and mobile, using JavaScript or TypeScript with WebGL/Canvas rendering.
Primary Use Cases
- ▸Browser-based 2D games
- ▸Educational games and e-learning apps
- ▸HTML5 mobile games
- ▸Prototypes and game jams
- ▸Advergames and marketing interactives
Notable Features
- ▸Scene-based architecture
- ▸WebGL + Canvas dual rendering
- ▸Arcade, Matter.js, and Impact physics
- ▸Sprite animations + tilemaps
- ▸Asset loading + input handling
Origin & Creator
Phaser was created by Richard Davey (Photon Storm) to provide a powerful, accessible, open-source framework for modern HTML5 game creation.
Industrial Note
Phaser dominates the HTML5 gaming market, especially in educational games, advergames, casino & gambling front-ends, interactive marketing campaigns, and lightweight browser-based entertainment.