What is Phaser?
Learn what Phaser is, what types of games you can build, and the core concepts of game development.
What you'll accomplish
Understand what Phaser is and core game development concepts.
Prerequisites
- Basic JavaScript/TypeScript knowledge
- Node.js installed
- No game development experience required
What is Phaser?
Phaser is a JavaScript game framework for making 2D games that run in web browsers. No downloads, no installs - players just open a URL and play.
Imagine you want to build a treehouse. You could:
- Chop down trees, mill lumber, forge nails... (hard!)
- Go to the hardware store and buy ready-made parts (easier!)
Phaser is like that hardware store for games. It gives you:
- Ready-made pieces (sprites, physics, sound)
- Tools to assemble them (the game engine)
- Instructions (documentation)
You focus on making your game fun. Phaser handles the technical parts.
What Can You Build?
Phaser excels at 2D games:
| Game Type | Examples |
|---|---|
| Platformers | Mario-style jumping games |
| Puzzle Games | Match-3, Tetris, logic games |
| Shooters | Space shooters, bullet hell |
| RPGs | Top-down adventure games |
| Card Games | Solitaire, poker, card battles |
| Endless Runners | Temple Run style |
| Physics Games | Angry Birds style |
Real Phaser Games
Many successful games are built with Phaser:
- Agar.io - Multiplayer cell eating game
- Slither.io - Snake-style multiplayer
- Countless browser games on gaming sites
Why Phaser?
| Feature | Benefit |
|---|---|
| Web-based | No downloads, instant play |
| Cross-platform | Works on any device with a browser |
| Free & Open Source | No licensing fees |
| Large Community | Lots of tutorials and examples |
| TypeScript Support | Type safety and IDE support |
| Active Development | Regular updates and improvements |
Phaser vs. Other Options
| Tool | Best For |
|---|---|
| Phaser | 2D browser games, quick prototypes |
| Unity | 3D games, complex games, mobile |
| Godot | 2D/3D games, open source |
| GameMaker | 2D games, visual programming |
| Construct | No-code 2D games |
Choose Phaser when:
- You know JavaScript/TypeScript
- You want games to run in browsers
- You're building 2D games
- You want free, open-source tools
Core Game Development Concepts
Before diving into code, understand these fundamentals:
The Game Loop
Every game runs a continuous loop:
┌─────────────────────────────┐
│ │
│ 1. Process Input │
│ (keyboard, mouse) │
│ ↓ │
│ 2. Update Game State │
│ (physics, logic) │
│ ↓ │
│ 3. Render Graphics │
│ (draw everything) │
│ ↓ │
│ Repeat 60 times/second │
│ │
└─────────────────────────────┘
This happens 60 times per second (60 FPS), creating smooth animation.
Movies run at 24 frames per second and look smooth. Games target 60 FPS because:
- You're interacting, so lag is more noticeable
- Higher frame rates feel more responsive
- Modern screens refresh at 60Hz (60 times per second)
Each "frame" is a complete picture. 60 pictures per second = smooth motion.
Sprites
A sprite is any visual object in your game:
- Player character
- Enemies
- Bullets
- Coins
- Background elements
Sprites are images positioned on the screen. They can move, animate, and interact.
Physics
Physics systems simulate real-world behavior:
- Gravity: Objects fall down
- Velocity: Speed and direction
- Collision: Objects can hit each other
- Bounce: Objects can bounce off surfaces
Phaser includes physics engines that handle this automatically.
Scenes
Games are organized into scenes (like screens):
- Main menu
- Gameplay
- Pause menu
- Game over screen
Each scene has its own logic and can transition to others.
Assets
Assets are the resources your game uses:
- Images: Sprites, backgrounds, UI
- Audio: Sound effects, music
- Data: Level data, high scores
You load assets before using them.
Your First Look at Phaser Code
Here's a simple Phaser game structure:
typescriptimport Phaser from 'phaser'; class MainScene extends Phaser.Scene { constructor() { super('MainScene'); } preload() { // Load assets this.load.image('player', 'player.png'); } create() { // Set up game objects this.add.image(400, 300, 'player'); } update() { // Game loop - runs every frame // Handle input, update positions, etc. } } const config: Phaser.Types.Core.GameConfig = { type: Phaser.AUTO, width: 800, height: 600, scene: MainScene, }; new Phaser.Game(config);
Key parts:
preload(): Load images, sounds, etc.create(): Set up game objects onceupdate(): Run every frame (60x per second)
Don't worry about understanding everything yet - we'll build this up step by step!
What You'll Build in This Track
By the end of this track, you'll:
- Set up a Phaser project with modern tooling
- Create scenes with proper lifecycle management
- Add sprites and animate them
- Implement physics for movement and collision
- Add audio for effects and music
- Build a complete game you can share
Hardware Requirements
Phaser games are lightweight. You don't need powerful hardware:
To develop:
- Any modern computer
- Node.js installed
- A code editor (VS Code/Cursor)
To play:
- Any device with a modern browser
- Even mobile phones work!
Common Questions
Frequently Asked Questions
Basic math helps (addition, multiplication), but Phaser's physics engines handle complex calculations. You mostly configure values like "gravity: 300" and Phaser does the rest.
Yes! Options include:
- Ad-supported browser games
- Premium games on itch.io
- Game licensing to portals
- Wrap in Capacitor for app stores
- Client work and freelancing
Phaser is excellent for beginners because:
- Web-based (easy to share and test)
- Strong documentation
- Instant feedback (refresh browser)
- No complex installations
Phaser is designed for 2D. For 3D, consider:
- Three.js (3D web)
- Babylon.js (3D web)
- Unity/Godot (full engines)
Some games fake 3D with 2D sprites (isometric view).
It depends on scope:
- Simple game jam game: 1-3 days
- Small polished game: 1-4 weeks
- Complex game: Months to years
Start small! Complete a tiny game before attempting big projects.
Verify Your Understanding
You've completed this lesson if you can:
Next: Set up a Phaser project with Vite and TypeScript.