A new tutorial about taking the SameGame engine and adding in object pooling.

Posted on 23rd Nov 2016. Follow @phaser_ and get the Phaser World newsletter.


From Emanuele Feronato: "This is an important update to the SameGame series because I making the game endless, allowing you to create most of the games mentioned in the post 10 successful games you can easily create starting from the SameGame engine and I am using object pooling to handle tiles management.

Object pooling is a technique which stores a collection of a particular object that an application will create and keep on hand for those situations where creating each instance is expensive.

In this case, each time you pick and remove tiles, their sprites should be destroyed. Then, new sprites should be created to replace the ones you just destroyed. That is, if you make a four tiles combo, you have to destroy the 4 old sprites and create 4 new sprites. Then you make a 11 tiles combo. This means 11 sprites destroyed and 11 new sprites to create.

Although I am sure Phaser has a good memory management and garbage collection, this can be very resource-consuming in the long run. So the idea is never to delete removed tiles, which will be temporarily stored in a repository (in this case an array) until a new tile is needed, and we just recover the previously stored tile."

Read More

Learn to code and lead your intrepid crew on a mission to save The Cloud in TwilioQuest, a PC role-playing game inspired by classics of the 16-bit era. Free forever, and available now for Windows, Mac, and Linux.

The first book on the creation of HTML5 cross platform games using Phaser 3 and other free software.
  • By Emanuele Feronato
  • 155 Pages
  • 28 Source Code Examples
  • Build a complete game from start to finish
  • Cross Platform
  • Scaling for devices
Buy Now