Simple Click Game - Phaser Typing CST Test
Loading…
Simple Click Game — Phaser Code
A simple Phaser game that increases a score when you click a sprite.
import Phaser from 'phaser';
class ClickScene extends Phaser.Scene {
constructor() {
super('ClickScene');
this.score = 0;
}
preload() {
this.load.image('star', 'assets/star.png');
}
create() {
this.star = this.add.sprite(200, 200, 'star').setInteractive();
this.text = this.add.text(10, 10, 'Score: 0', { fontSize: '24px' });
this.star.on('pointerdown', () => this.addScore());
}
addScore() {
this.score++;
this.text.setText('Score: ' + this.score);
}
}
new Phaser.Game({ type: Phaser.AUTO, width: 400, height: 400, scene: [ClickScene] });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.