Moving from Phaser 2 to 3
Moving from Phaser 2 → 3: an incomplete guide
Scenes have replaced states (and the game object… mostly)
- I found that the best thing was to ask myself what this or that line was meant to accomplish, and then to search labs.phaser.io for a Phaser 3 example of that task.
- Usually the issue is just that a function has moved, or some property now requires a setter.
- There's a real migration guide here: part 1, part 2
Animations now belong to a global animation manager
- the default camera is now
- factories are part of the scene:
No more sprite.exists
- they must be created (using
.create) before they're added
- changing the frame for a sprite requires
- in fact,
sprite.frame = x will break rendering for that sprite
Turn retrofonts into bitmapfonts
sprite.exists = x →
sprite.setVisible(x), depending on what you're trying to accomplish
- retrofonts are gone as a first-class thing
- instead use
RetroFont.Parse on a config object to create a bitmapfont and add that.
New top-level namespaces
game.load.tilemap(key, url, null, Phaser.Tilemap.TILED_JSON) →
- AFAICT, the ability to pass an already-loaded json tilemap (i.e. the third argument to
load.tilemap) is gone. I had to let Phaser fetch my tilemaps, which in turn meant having Webpack treat them as "data" files and not JS. The procedure for that is annoyingly nonobvious.