Basic Phaser 3 Information

Phaser 3

Phaser 3 is a robust Javascript powered html5 game framework. Almost any 2d game that can be thought up, can be implemented in Phaser. Thanks to a well organized api, and functionality that handles audio,physics,input game creation time is much shorter.

Phaser 3 API

Why use Phaser 3?


The Game Object

The Game object is the main object of the program. It accepts a Config object and after starting should generally be left alone.

Game Object API Information

Example of initializing a Game object with a config file

game = new Phaser.Game(config);

Scenes

Scenes are useful for representing level's and stand alone sections of the game. Examples would be a inventory scene for items, a start scene, end game scene, and gameplay levels. Scenes can be stopped,paused,started,resumed, and more.

Scene Manager Information


Input

Phaser supports various input options. Gamepads,keyboard,mobile touch, mouse, and more. This system can allow multiple player control if set up correctly.

Input Information

Example of input handling

When a mouse click is detected the callbackfunction is executed.

this.input.on('pointerdown', callBackFunction, this);

Audio

Phaser has a built in audio system, this allows music to be looped and switched out, sounds to play on events, and more.

Audio Manager Information

Example of audio handling

A sound file linked with the keyword 'backgroundMusic' is to be looped. The assigned bgMusic can be called to play or stop music.

this.bgMusic = this.sound.add('backgroundMusic', {loop:true}); this.bgMusic.play();

Assigned jumpsound holds a soundFX keyed to the word 'jumpFX' and plays when called, does not loop.

this.jumpSound = this.sound.add('jumpFX'); this.jumpSound.play();