game

My Journey From Unity3D to Phaser.io

By 12th January 2018 No Comments

When you have a passion for games then the platform doesn’t matter. A few years ago we used to play games mostly on Nintendo, then PC games came into existence and now we have games in our pockets in the form of a Smartphone.

But if you are a game developer then it matters a lot which platform you work on. Thanks to Unity 3D which is a heaven for game developers as it is the most flexible game engine and allows us to publish our games to almost all the game platforms available. But a few months ago, I doubted Unity in its capabilities to export stable Web browser games. Although it has a WebGL export option, it didn’t go well with my slot game. And most of the issues I had were on mobile browsers. Compromising with my game quality was not an option, so I spent few days searching for an option which can allow me to build a game specifically for web browsers with the best quality.

There were so many options (here is a list), and after searching some forums and looking at the Made with a section of these engines I made up my mind to go with Phaser.io. It is not easy to get comfortable with Phaser when you come from Unity 3D background where you can develop a complete game without writing a single line of code. In Phaser, the initial setup only will make you feel low and you won’t be able to see results until you write a few lines of code. I will try to put here some comparison points of my experience on game development with both the engines.

  1. Canvas is the most beautiful UI builder in Unity as it resizes and scales with some tweaks in the inspector. Phaser too has different scaling options, and I used RESIZE option which gives you a function to resize and re-position all elements of your game manually (if you want your game to look perfect on all resolutions). I highly recommend RESIZE option. Although it includes calculations and hard work which Unity canvas handles easily. It also gives you the freedom to make your UI look perfect, which Unity lags sometimes.
  2. Import an IMAGE -> Drag it on the hierarchy and your game gets its first character. That’s how you draw an image in Unity. But if you want to display the same image using Phaser, after importing you first have to preload the image and assign it a ‘key’. Using this key you add the image to your game which is displayed on the screen. (My game consisted of many images(30–40), and I did not want to write pre-loading for each and every image. Neither I wanted to write the keys and then paths in my code which makes my code look ugly. So I went with a JSON approach to keep the preloading and creation of image separate and more manageable.
  3. Animations make your game more interactive and interesting. I mostly used frame based animations in my game as these looked best. In Unity, I use frame animation with Animation window which I don’t like to use much. But in Phaser you just have to write 2–3 lines of code to run your animation and the interesting thing is you can pause and resume the animation anytime without affecting timescale of your complete game.
  4. I only used C# when I worked with Unity, but Phaser requires Javascript. So I have to learn a little bit of Javascript for that. In the beginning, it is difficult when you come from an OOP language. In Javascript, there is a concept of prototype and you can define anything anywhere.

This covers a high-level comparison of these two engines. I still develop my games meant for web only in Phaser as I have more access to the web-based parameters. So, I just love playing games and moreover developing them makes it even more fun. It doesn’t matter to me which process I follow to developing them, they just need to be amazing 🙂 

Leave a Reply

Comments