Navigation

State Manager Video and Survey

Published on 11th November 2016

image

First up, something important: It's been a couple of months since I released Phaser 2.6.2. And although development on Phaser 3 is rocking along, I'm well aware that there are issues in GitHub that still need solving. Or perhaps even more frustratingly, I already did fix them in the dev branch, but they've since merged into the Phaser 3 work.

So I've put together a quick survey to find out if you think I should pause work on v3 briefly, and release Phaser 2.7, after which I can return to v3. Please take the survey, it's literally just 2 questions, and will be used to give me an idea where to focus my dev time over the next couple of weeks.

Phaser 3 State Manager Video

It's been quite an exciting week, from a development point of view at least. After some serious work on the new State Manager I created a video that demonstrated it in action. Turn the audio up to hear me waffle on about what's happening on-screen. I need to get a better microphone, but otherwise I'm quite happy with how the video turned out. Sadly, the software I use only captures at 30fps, even though it was all running at a smooth 60fps.

As I explain in the video, States can now run in parallel. You can think of them as being fully self-contained packages. They have their own Loaders, Physics systems, Tween Manager, etc. And most importantly display objects belong to just that State. Someone said on Slack "does this mean I can't make a Preload State any more?", which is a valid question. The answer is that although States themselves are entirely isolated, the resources they access are not. So they still pull textures from the global texture manager, and files loaded via a State loader, are still placed into the global cache. So an image loaded from one State is instantly available in any other State.

States also have their own main loop and internal frame rate. This is really important, as it allows you to configure a State that updates at whatever interval you require (once per second? no problem). There's no need to spend time processing a State if you don't have to. I'll show the variable frame rate and new interpolation system in a future video.

One other thing I did in the video, which I forgot to mention at the time, is used the new Transform system. All Game Objects in Phaser 3 use the new Transform class, and one feature it has is that you can parent the Transform of a Game Object to any other Transform - no matter where on the display list that is. I use this in the video to handle the window with the icons in. The icons are all part of a single Container. A Container is a non-visual way of grouping objects together, much like a Phaser.Group. However I add the Containers transform as a child of the window image itself, so as the window image is dragged around, its own transform, which has the container as a child, is updated, and that flows down to all children (the icons). It's quite hard to explain, although I guess the main take-away from it is that objects can now be grouped however you like, and that grouping no longer has to influence the way they are transformed in your game.

Onwards and Upwards

As well as the State Manager I also spent time re-working the Main Loop, Input Manager, and last night made a start putting Arcade Physics back in too. The pieces are slotting in to place. Depending on the survey results depends what I focus on next week, either way though, Phaser will be advanced a little bit more :)