Phaser 3 FAQ (from Discord)

Frequently Asked Questions

This FAQ comes from the Phaser Discord community but is really useful to have here for new users to Phaser. Be sure to join Phaser on Discord. You can help update their FAQ via the linked GitHub repo.

I’m new to Phaser, what should I do?

Last Updated: 2018-05-17

The key to learning game dev / Phaser is to just build stuff, it doesn’t need to be good or even complete. The more you program the more you know and the easier it is to make what you imagine real.

That said, if having a list of things that help you get started is useful we’ve compiled a bunch of introductory guides. They’re ordered based on how much you’re expected to already know and we’re always happy to take
suggestions about new stuff that should be added to the list.

  1. Getting Started — This introduces you to the basics of how to run your game and gives provides a super simple game you can create.
  2. Making your first game — Once you’re comfortable with running a server and editing code work through this. It introduces some basic systems involved in a Phaser game.
  3. How to create a game — This is a similar slice of information as Making your first game but covers enough different information that it’s worth reading through as well.
  4. How to structure your code — This isn’t about how to program exactly but talks a little bit about how to organize your project so that it’s easy to keep building on what you’ve got. Optional reading but I feel it’s an important bit of information.
  5. Ask for help — Get involved in the community! It’s dangerous to go alone, take a friend, and don’t be afraid to ask for help.
  6. How scenes work — Goes into more detail about how scenes can work and can fit into your game.

If you’d like to help this list grow we’d like to add:

  • Some guides about javascript basics etc
  • Some simple sample projects with documentation

Where are the documentation and examples?

Last Updated: 2018-09-16

The Phaser examples page is a rich source of code samples demonstrating various aspects of the Phaser framework.

The Phaser API docs is an ever-improving source of information and great for self-directed exploration.

How do I get started with multiplayer games?

Work in progress, last updated: 2018-06-20

Right now this is just a collection of links that potentially may be useful:

Is there a ScaleManager in v3?

Last Updated: 2018-08-13

Not yet, but one is in the works and planned for Phaser 3.16! It won’t be as complex as the one in Phaser CE, but should do a good job in helping you scale your game to fill the entire screen.

In the meantime it’s not too bad to roll your own solution. We even have some examples:

  • Example page from DannyT includes functional examples built using some of the principles discussed in the following links.
  • This gist from Str1ngS bundles some scaling functionality into a class and demonstratse how to hook it into your game; the orientation and content references are HTML elements in your page that you can use to implement “wrong orientation” overlays as described in this post.
  • This thread includes a (Haxe) code sample from community member Antriel.
  • A codepen sample linked from Samme includes another promising solution.
  • Scaling without framework support Emanuele works through the principles of scaling your game regardless of framework support.

Tell me the story of Phaser v3 and Typescript

Last Updated: 2018-05-08

Typescript defs are now available at photonstorm/phaser3-docs. That file is the one you want to use.

Is there a guide to porting my v2/CE project to v3?

Last Updated: 2018-03-14

Not yet. There is a partial guide in Newsletter issue 116 in the section named Moving from Phaser 2 to Phaser 3 (Part 1). Part 2 is in issue 118.

The API is similar enough that you will feel comfortable once you’ve figured out where things live but there is no mechanical solution to making a CE project run in v3. In that way, it’s definitely possible to make the jump for an existing project.

That said, enough essential things are different (no ScaleManager yet, Scene works differently than State, etc.) that it takes a little thinking. The work to describe how all the old CE concepts map into v3 is planned
but currently incomplete.

Should I use Phaser CE or v3?

Last Updated: 2018-02-10 / 2018-10-28

tl;dr: One of our members made a video talking about deciding whether or not to use v3: go watch it (thanks to Wild)! For production stuff, Phaser CE is still a good choice, but if you’re learning Phaser and/or feeling adventurous then v3 is a pretty good bet, and it’s becoming better every day.

That video was recorded Feb 10th. Since then we (the community at large) have leveled up several times about how well we understand and how much we’ve experimented with v3. Tutorials are beginning to emerge and several patch releases have appeared fixing bugs and adding previosly missing features.

Broadly speaking getting into V3 is much easier than it was but still seeing quite a bit of development. If you’re adventurous and willing to dig v3 is a good place to be. The API is cleaner than CE and it’s definitely the future of Phaser so learning it to start with is probably a good move.

If you need something exceptionally stable and battle worn that you can take into production right now then you probably still want to stick with CE for the time being. By the numbers most deployed Phaser games are CE which means more time has been spent understanding it’s edge cases. You’re not going to see as many bugs or API changes than working off V3 but you’re also not going to see any improvements.

My game behaves inconsistent/stops running while in the background

Last Updated: 2018-10-26

Modern browsers place several restrictions on websites that run in the background. This usually means background tabs, but can also influence windows that are unfocused or partly hidden by another window. When in the background, requestAnimationFrame is not triggered, and it may be throttled when the website is unfocused. This means that Phaser’s update loop won’t run. Additionally, timers in background tabs may run less frequently than they normally would. Chrome only executes timers once per second, while Firefox has similar policies. The timers may be throttled even more in some cases. Playing audio or using websockets are usually an exception to this additional throttling.

More details:

3 Likes