Published on 22nd April 2016
Welcome to Issue 27 of Phaser World
I'm very pleased to say that Phaser 2.4.7 was released today. This version contains stacks of fixes and updates, and I've dedicated this weeks Developer Progress section to talking about three of its new effects in depth.
There's an interesting discussion taking place in the forum about what we should include in Phaser 2.5.0. We're after votes for features, so please, if you haven't done so, leave your feedback there.
With the LowRez Game Jam ending and Ludum Dare 35 starting the following day we've been inundated with some great new games. You'll find several this issue, and lots more next week. Finally we've 5 new tutorials this week as well. So all things considered, plenty of playing and reading!
Until next issue, happy coding. Drop me a line if you've got any news you'd like featured (you can just reply to this email) or grab me on the Phaser Slack channel.
News
The latest release of Phaser is now ready, with some great new features for your games.
The Create a Vertical Endless Runner Book gets a free update.
Building Multiplayer Games with Phoenix and Phaser.
Games made with Phaser
Game of the Week
A four-player, platforming, pixel-art deathmatch.
Staff Pick
Help baby Seb get his milk in this speed run adventure game created for LowRezJam.
Take on the role of a deity and gain, or smite, your followers as they battle an Ogre.
Multiplayer space combat written in 48 hours for LD35.
Control the ghost, find the keys and open the lock. Potatoes are your enemies!
Phaser Tutorials
How to restrict the drag movement of a sprite to both X & Y axis.
How to publish your game on Facebook, using Facebook login, Share and CPMStar ads.
The Phaser Spriter Player gets an update and new examples.
How the Bullet class was created in the game A Modest Platformer.
Creating an animated MDM Theme for Linux with Phaser.
Development Progress
After another round of bug fixing I'm very pleased that Phaser 2.4.7 is now released. Grab it from the Phaser site, GitHub or your favourite CDN. I wanted to use the space here this week to talk about a couple of its new features:
Camera Shake
Shake the camera by calling camera.shake. You can provide an intensity value, which controls how much the camera shakes. Smaller values mean less shake, and we're talking really small values here, like 0.01 for a 'slight tremor'. You can also specify the duration of the shake, given in milliseconds. The default is 500ms. There is a 'direction' argument, which allows you to shake the camera either just horizontally, vertically, or both. And finally 'shakeBounds'. This lets you control if the camera can shake the world beyond its bounds, revealing whatever your game background colour is behind it.
Internally the camera shake effect works differently depending if you're using Canvas or WebGL. In WebGL mode it simply uses the Pixi renderer offset property, changing it to whatever the shake values are. This is reset each frame. In Canvas it's a little different, instead the shake values are applied to the game objects transform matrix as they are rendered. It never updates the matrix, or adjusts the objects actual on-screen coordinates, it's purely applied during render, and reset again each frame.
Camera Flash
This is perfect for things like impact events. If the player gets hit by a bullet, then you could flash the screen red very quickly. It's handled by calling camera.flash. You can provide the colour to flash to (the default is white) and the duration. This effect works best for really short durations.
Camera Fade
A camera fade is likely more useful to help with transitions between scenes. For example facing the camera off to a nice black colour, then bring it back in again when the new scene has loaded. As you may expect by now you create the effect by calling camera.fade. As with flash you can specify the colour and duration of the effect. The difference is that once the effect has finished, your game will remain solidly filled with the colour of your fade. So if you fade to black, your game will remain utterly black (even if you change State), until you call camera.resetFX.
Internally the flash and fade effects work by adding a single Graphics object onto the display list, above the game world. This Graphics object contains a single rectangle shape. Each time the effect is called this rectangle is filled with the colour and opacity required, fading up (or down) to reach the desired colour, over the duration given. Once it reaches the given colour in a flash effect it has its alpha set to zero, which prevents it from being considered for rendering by the game render loop. The 'fx' graphics object sits above the World in the display list owned by the Stage. So if you have any code that adds additional objects to the stage display list, that you want to be impacted by a flash or fade effect, then you will want to be sure they are inserted correctly (after the world, before the fx object).
Geeky Links
Another small selection of great geeky links.
DeckHub - It's like TweetDeck for GitHub.
Neko Atsume hats - It's fair to say I was addicted to this game, and now there are super cute hats!
The Xenon 2 theme as played on a banjo. Seriously cool :)
Phaser Releases
The current version of Phaser is 2.4.7 released on April 22nd 2016.
Phaser 2.5.0 is now in development. Follow progress on the GitHub dev branch.
Please help support Phaser development on Patreon.
Have some news you'd like published? Email [email protected] or tweet us.
Missed an issue? Check out the Back Issues page.