Basic Phaser 3 Information
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.
Why use Phaser 3?
- Faster development time
- Built in physics engine
- Active Community
- Built in audio/input handling
- Free
The Game object is the main object of the program. It accepts a Config object and after starting should generally be left alone.
Example of initializing a Game object with a config file
game = new Phaser.Game(config);
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.
Phaser supports various input options. Gamepads,keyboard,mobile touch, mouse, and more. This system can allow multiple player control if set up correctly.
Example of input handling
When a mouse click is detected the callbackfunction is executed.
this.input.on('pointerdown', callBackFunction, this);
Phaser has a built in audio system, this allows music to be looped and switched out, sounds to play on events, and more.
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();