Latest Post

Transition from one state to another state in Phaser

If you followed previous articles I wrote on making of a responsive game in Phaser, one task was to implement smooth transition from one state to another in the game. Phaser states work by loading new state in the view and removing old state from the view which happens instantly and does not give a transition effect as if we are changing the state (or screen). In a polished game you would want to implement something which gives an impression of a transition from one screen to another. For example a sliding effect where player sees one screen sliding out of the view and another screen sliding in giving impression that something is changing in the game. Cristian Bote wrote a nice Phaser plugin State Transition Plugin for Phaser which gives many options to achieve this and good thing about it is that you don’t have to do much and can get away with changing a couple[…]

Making of a responsive game in Phaser: Part 3

In part one and part two of this article series, we designed “Main Menu” screen and did some code to manage scaling of it for various resolutions and aspect ratios. “Main Menu” screen followed the same layout for both portrait and landscape orientations. In part three we will be working on actual “Game” screen and implement different layouts for portrait and landscape orientations. The game is a number puzzle which contains a 6×6 number tiles grid, 2 additional tiles for displaying current and best scores and another 3 icons for various options. In the image below you will see the alignment of various elements in portrait and landscape orientations. The layouts are different here. In portrait orientation the grid is centered with other elements placed on top and bottom of it while in landscape orientation the grid is moved to the left which takes 2/3rd of the available width and rest of the[…]

Making of a responsive game in Phaser: Part 2

In part one of this series we did a “Main Menu” screen design for our game which can be read here. Now its time to dive into the code. In order to reach to the “Main Menu” screen, we are going to use 3 states. The first state will be “Boot” state which is going to set the scale mode to RESIZE. Its also going to load an image which will be displayed while rest of the assets are loaded in the next state which will be called “Loading” state. Once all assets are loaded in the “Loading” state, we move to “Main Menu” state where all action happens. var TheGame = { }; TheGame.Params = { baseWidth: 1920, baseHeight: 1080, iconSize: 364 }; TheGame.Boot = function (game) { }; TheGame.Boot.prototype = { init: function () { this.scale.scaleMode = Phaser.ScaleManager.RESIZE; }, preload: function () { this.load.image(“loading”, “loading.png”); }, create: function () { this.state.start(“Loading”); } }; TheGame.Loading =[…]

Making of a responsive game in Phaser: Part 1

I first started reading about Phaser around 5 months back and since then I have been planning to write games in Phaser. After studying some material online I finally decided to write a few games to get used to the framework. I wrote a few games which were more like practice games and then started digging further into it to make something more polished. Finally I decided to write a game and publish a series of articles as I encountered scenarios which I wanted to manage in the game but could not find enough tutorials for help. Scaling the game A very basic requirement for HTML5 games is to be able to scale to the resolution of the device on which the game is running. Since HTML5 games can run both on pc as well as mobile, there are thousands of resolutions and aspect ratios which the game needs to support. Now this is somewhat hardest part[…]