phaser README

The project's README from github.com/phaserjs/phaser. As one markdown file: README.md.

Phaser - HTML5 Game Framework

Phaser Banner

Discord JSDelivr GitHub

Phaser is a fast, free, and fun open source HTML5 game framework that offers WebGL and Canvas rendering across desktop and mobile web browsers and has been actively developed for over 13 years.

Games can be built for the web, or as YouTube Playables, Discord Activities, Reddit games, Twitch Overlays or compiled to iOS, Android, Steam and native apps using 3rd party tools. You can use JavaScript or TypeScript for development. Phaser supports over 40 different front-end frameworks including React and Vue.

Phaser is commercially developed and maintained by Phaser Studio Inc along with our fantastic open source community. As a result of rapid support, and a developer friendly API, Phaser is currently one of the most starred game frameworks on GitHub.

Interested in learning more? Click the image below to watch our intro video.

YouTube


Installing Phaser from NPM

Install via npm:

npm install phaser

Then import it in your project:

import Phaser from 'phaser';

Using Phaser from a CDN

Phaser is on jsDelivr which is a "super-fast CDN for developers". Include either of the following in your html:

<script src="//cdn.jsdelivr.net/npm/[email protected]/dist/phaser.js"></script>
<script src="//cdn.jsdelivr.net/npm/[email protected]/dist/phaser.min.js"></script>

It is also available from Cloudflare's cdnjs:

<script src="https://cdnjs.cloudflare.com/ajax/libs/phaser/4.2.1/phaser.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/phaser/4.2.1/phaser.min.js"></script>

Create Phaser Game App

The easiest way to get started quickly with Phaser is our create-phaser-game app. This CLI tool presents an interactive selection of official project templates and demo games. Issue the command, answer some questions and the app will download and configure the right package for you.

npm create @phaserjs/game@latest
npx @phaserjs/create-game@latest
yarn create @phaserjs/game
pnpm create @phaserjs/game@latest
bun create @phaserjs/game@latest

We support Vue.js, React, Angular, Next.js, SolidJS, Svelte and Remix with Vite, Rollup, Parcel, Webpack, ESBuild, Import Map and Bun. Most come in both JavaScript and TypeScript versions.

View the create game app tutorial.

How Big is Phaser?

Don't be alarmed if you look at phaser.js and see a file over 8 MB. Over 84% of that is inline documentation - JSDoc comments, type annotations, and detailed method descriptions that power the TypeScript definitions and API docs. It's there for your IDE, not for your players.

The minified build, phaser.min.js, strips all of that out and comes in at 345 KB with standard gzip web server compression. This is the full version, with every feature included, but is still smaller than most texture images. You can reduce it further still by tweaking the build settings to exclude features your game doesn't need.

Build Raw Size Compressed (gzip)
phaser.js (with docs) 8.23 MB -
phaser.min.js (full) 1.29 MB 345 KB
phaser-arcade.min.js 1.18 MB 313 KB

Why Phaser?

What's New in Phaser 4

Phaser 4 is a major release built on a brand-new WebGL renderer. The entire rendering pipeline from v3 has been replaced with a modern, node-based architecture that manages WebGL state properly, handles context loss gracefully, and is significantly faster. If you've built games with Phaser 3, the public API is mostly familiar - but under the hood, everything has changed for the better.

Here are the headline features. For the full picture, see the v4.0 Changelog and Migration Guide.

New Render Node Architecture

The v3 pipeline system has been replaced with a clean, node-based renderer. Each render node handles a single task, WebGL state is fully managed, and context restoration is built in. The result is a renderer that's faster, more reliable, and much easier to extend with custom rendering logic. Quads now use index buffers, reducing vertex upload costs by a third. Multi-texture batching is smarter, avoiding unnecessary batch breaks on mobile. And the whole system uses just-in-time rendering - nothing hits the GPU until it absolutely has to.

Unified Filter System

FX and Masks from v3 have been unified into a single, powerful Filter system. Filters can be applied to any game object or camera - no more restrictions on which objects support effects. Every filter takes an input image and produces an output, usually via a single shader, so they're all mutually compatible.

v4 ships with a huge library of built-in filters: Blur, Glow, Shadow, Pixelate, ColorMatrix, Bloom, Vignette, Wipe, and many more. New additions include ImageLight for realistic image-based lighting, Blocky for pixel-art-friendly pixelation, GradientMap for palette-swap effects, Quantize for retro dithered palettes, Key for chroma keying, NormalTools for normal map manipulation, and Blend which brings all 27 Canvas blend modes to WebGL.

Masks are now a filter too, more powerful than ever. A Container full of filtered, masked objects can itself be used as a mask source.

SpriteGPULayer - Render a Million Sprites

SpriteGPULayer is a new game object designed to render massive numbers of sprites. Where standard Phaser rendering handles tens of thousands of sprites comfortably, SpriteGPULayer handles a million or more, up to 100x faster.

It works by storing all member data in a static GPU buffer and rendering everything in a single draw call, skipping the per-frame CPU-to-GPU upload that's normally the main bottleneck. Members aren't just static, either - each one supports GPU-driven animations on position, rotation, scale, alpha, tint, and frame, with a full set of easing functions. Per-member scroll factors enable parallax backgrounds, and non-looping mode supports one-off particle effects. It's perfect for bringing complex, animated backgrounds to life without touching your frame budget.

TilemapGPULayer - Render Millions of Tiles

TilemapGPULayer renders an entire tilemap layer as a single quad. The shader cost is per-pixel, not per-tile, so it can display up to 4096 x 4096 tiles with no performance penalty for tile count. It also produces perfect texture filtering across tile boundaries - no seams, no bleeding. If you need large maps on screen at once, especially on mobile, this is the way to go.

Overhauled Tint System

Tint has been reworked with color and mode as separate concerns. Six tint modes are available: MULTIPLY, FILL, ADD, SCREEN, OVERLAY, and HARD_LIGHT. The new setTintMode() method gives you explicit control, and BitmapText tinting finally works correctly.

New Game Objects

Improved Lighting

Lighting is now as simple as sprite.setLighting(true) - no pipeline juggling required. Objects can cast self-shadows based on their own texture, lights have an explicit z height value, and lighting works across most game objects including BitmapText, Particles, TileSprite, and both tilemap layer types.

Shader and TileSprite Improvements

The Shader game object has been rewritten with a cleaner config-based API (ShaderQuadConfig), and GLSL loading now uses standard #pragma directives that work with syntax checkers. TileSprite has been rebuilt with a new shader that supports texture atlas frames and tile rotation - no more whole-texture-only limitation.


AI-Assisted Game Development

Phaser has been part of the training data for every major frontier LLM. Models from Anthropic, OpenAI, Google, and others understand the Phaser API deeply and can generate game code, debug rendering issues, set up physics, and build scene structures out of the box. Tools like Claude Code, Cursor, Codex, Antigravity, and GitHub Copilot can scaffold entire Phaser games and implement features from natural language descriptions.

AI Agent Skills

This repository includes a comprehensive set of AI agent skills covering every major Phaser subsystem - scenes, physics, input, animations, tilemaps, tweens, particles, cameras, and much more. Point your AI coding agent at the skills/ folder and it will understand Phaser 4's architecture, APIs, patterns, and gotchas in depth. Tell it to create a game and it will know the right way to structure scenes, load assets, set up physics, and handle input - all using idiomatic Phaser 4 code.


Phaser TypeScript Definitions

Full TypeScript definitions can be found inside the types folder. They are also referenced in the types entry in package.json, meaning modern editors such as VSCode will detect them automatically.

Depending on your project, you may need to add the following to your tsconfig.json file:

"lib": ["es6", "dom", "dom.iterable", "scripthost"],
"typeRoots": ["./node_modules/phaser/types"],
"types": ["Phaser"]

API Documentation

Read our full API Documentation at https://docs.phaser.io/. Use the links at the top of the page to navigate the namespaces, classes, events and Game Objects and also to use the search box.

We maintain documentation for the most recent versions of Phaser on this site.

Getting Started

We recommend the following to begin your journey:

New tutorials are being published every week, so check our site for more.

Source Code Examples

We have created hundreds of examples and they are all available with full source code and assets.

Browse our Phaser Examples site.

Phaser Sandbox

The Phaser Sandbox is a fully-configured online editor, fully updated for Phaser 4, ready to go direct in your desktop browser. It's loaded with the latest version of Phaser and packed full of handy features. Register for a free Phaser account to create and save your own sandbox entries. Or view one just like this.

Phaser Plugins

Super community member RexRainbow has been publishing Phaser content for years, compiling an impressive catalogue of plugins that all Phaser developers should be aware of.

You'll find Phaser Plugins that extend the framework with features such as UI controls, text input boxes, Firebase support, Finite State Machines and lots more. His set of Phaser Notes are also invaluable reading.

Migrating from Phaser 3

Phaser 4 keeps most of the public API you know, but there are important breaking changes - the renderer, tint system, FX/Masks, Shader API, lighting, and several removed classes (Point, Mesh, BitmapMask) all need attention. We've written a detailed Migration Guide with a checklist to walk you through it.

We've also included a dedicated v3 to v4 migration skill in this repository. Point your AI coding agent at it and tell it to migrate your Phaser 3 game - it understands every breaking change and knows the exact v4 replacements.

Change Log

We meticulously keep track of new features, updates and bug fixes in our change logs. Each version of Phaser has its own change log:

Have fun!

Grab the source and join the fun!

Phaser wouldn't have been possible without the fantastic support of the community. Thank you to everyone who supports our work, who shares our belief in the future of HTML5 gaming, and Phaser's role in that.

Happy coding everyone!

Cheers,

Rich and the whole team at Phaser Studio

boogie

Visit the Phaser website
Play some amazing games
Learn By browsing our API Docs or Support Forum
AI Skills Point your AI agent at our Phaser Skills for deep framework knowledge
Code Examples? We've over 2000 Examples to learn from
Read the weekly Phaser World Newsletter
Be Social: Join us on Discord and Reddit or follow us on Twitter

Powered by coffee, anime, pixels and love.

The Phaser logo and characters are © 2011 - 2026 Phaser Studio Inc.

All rights reserved.

"Above all, video games are meant to be just one thing: fun. Fun for everyone." - Satoru Iwata

phaser (phaserjs/phaser)

Searching Database…

40.5K ·GitHub
这是什么?Phaser 是一个快速、免费、开源的 2D 游戏框架,用于开发可在桌面和移动端浏览器中运行的 HTML5 游戏,支持 WebGL 或 Canvas 渲染。它已经持续开发超过 13 年。
Phaser 是需要自己写代码的框架,还是自带可视化编辑器?它是一个代码框架:你用 JavaScript 或 TypeScript 基于场景(scene)风格的 API 来写游戏。Phaser Sandbox 是一个可选的在线演练场,但并没有可视化的游戏编辑器。
怎么把它装到我的项目里?从 npm 安装 phaser 包并引入,或者用 script 标签从 jsDelivr、Cloudflare cdnjs 之类的 CDN 引入。create-phaser-game CLI 还能基于官方模板生成一个开箱即用的项目,支持 Vue、React、Angular、Next.js、SolidJS、Svelte 和 Remix。
必须搭配 React 或其他框架使用吗,还是可以只写纯 JavaScript?纯 JavaScript 和 TypeScript 单独用完全没问题。README 中说 Phaser 支持超过 40 种前端框架,包括 React 和 Vue。
phaser.js 文件怎么有 8 MB 多?对浏览器来说是不是太大了?完全不用担心:其中 84% 以上是内联文档,用来支撑你的 IDE 和 TypeScript 类型定义。压缩后的构建产物原始大小为 1.29 MB,gzip 后只有 345 KB,而且通过构建配置还能去掉用不到的功能。
第一次做游戏的人适合用它吗?适合,它对新手非常友好:有入门指南、'Making your first Phaser Game' 教程、一本免费的 500 页图书、700 多个教程,以及数百个附带完整源码的示例。
用 Phaser 做的游戏到底能在哪些地方运行?首先是桌面和移动端浏览器,另外还有 YouTube Playables、Discord Activities、Reddit 游戏和 Twitch 直播悬浮层。借助第三方工具,同一个游戏还可以打包成 iOS、Android、Steam 和原生应用。
Phaser 真的免费吗?做商业游戏也免费吗?是的。仓库采用 MIT 许可证,README 也强调它快速、免费、开源——由 Phaser Studio Inc 与开源社区共同进行商业化开发。
玩家需要游戏显卡才能用 WebGL 渲染吗?不需要任何特殊硬件,文档也没有提到相关要求:游戏通过 WebGL 在普通桌面和移动浏览器中渲染,同时保留 Canvas 作为兼容方案。
Phaser 4 有什么新东西?全新的基于节点的 WebGL 渲染器、统一的 Filter 系统(模糊、发光、泛光、阴影等)、单次 draw call 就能绘制一百万以上精灵的 SpriteGPULayer、支持最大 4096x4096 图块的 TilemapGPULayer,以及只需调用一次 setLighting(true) 即可开启的光照。
AI 编程助手能开发 Phaser 游戏吗?可以。仓库内置了一整套覆盖各个子系统的 AI agent skills,Phaser 也表示主流大语言模型已经很熟悉它的 API。把 Claude Code、Cursor、Codex、Antigravity 或 GitHub Copilot 指向 skills/ 文件夹,就能得到地道的 Phaser 4 代码。
除了渲染,它还内置了什么?完整的资源加载器、动画系统、输入处理、摄像机、图块地图、粒子、补间动画,以及两个物理引擎:Arcade 和 Matter.js。
我有一个 Phaser 3 的游戏,升级起来麻烦吗?公开 API 大体上还是熟悉的,但有一些破坏性改动:渲染器、着色(tint)系统、FX/遮罩、Shader API 和光照都变了,Point、Mesh、BitmapMask 等类被移除了。仓库里附带一份清单式的迁移指南(Migration Guide)。
Creator
phaserjs
Size
468.2 MB
Stars
40.5K
Age
13y
Commits · 90 Days