Skip to content

Latest commit

 

History

History
221 lines (163 loc) · 11.3 KB

File metadata and controls

221 lines (163 loc) · 11.3 KB

Frequently Asked Questions

(that we have answers to)

Also note that @samme maintains another FAQ that you can check out!

What is Phaser 4? Didn't Phaser 3 just come out?

_Last Updated: 2019-10-23

Phaser 4 is like an evolution of Phaser 3. Keep the best parts and improve the rest. Phaser 4 will be written in TypeScript and be more modular and tree-shakeable. The development has just started, but the plan is for you to be able to either use a Phaser 3-like API, or the new style of importing and using just what you need. You can read more about it in Rich's patreon post

Will I have to use TypeScript with Phaser 4?

_Last Updated: 2019-10-23

No! When Phaser 4 is released, there will be prebuilt .js and .min.js made available, just like you're used to. If you consume the Phaser source directly, you can even setup your bundler to compile the TypeScript code for you, while still writing your code in JavaScript!

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.

Disclaimer: the author of this list wrote the structure and scenes posts

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.

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 is the documentation and/or examples?

Last Updated: 2018-09-16

The [phaser examples page][labs] 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:

How do I scale a Phaser 3 game? Is there a ScaleManager in v3?

Last Updated: 2019-3-29

With the release of 3.16, Phaser now comes with a ScaleManager built in! Examples on it can be found here.

If you're not on 3.16 or above you'll have to roll your own solution. Heres 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 demonstrates how to hook it into your game; the orientation and content references are HTML elements in your page that you cane 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
  • James Pierce posted the code he uses for scaling a game across devices

Tell me the story of Phaser v3 and Typescript

Last Updated: 2019-10-08

Typescript defs for Phaser have been available for a long time now. They are considered stable enough, and have been included in the types folder of the Phaser repository since Phaser 3.17. If you install Phaser with npm, that means you already have them downloaded. Before 3.17 they were available at photonstorm/phaser3-docs. If you are stuck on an old version, that file is the one you want to use, just make sure to use the one corresponding yo your version. Previously, phaser#3224 was the official tracking ticket for typescript support in Phaser.

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 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:

How do I post code?

Last Updated: 2018-12-06

If you have a small bit of code (less than about 15-20 lines) to share the easiest approach is using the formatting support built into Discord. This means using ```javascript on a line by itself then entering your code:

code format sample

If you have a longer or multi-file segment of code you should create a new gist or codepen.