Skip to main content

· 2 min read
Daniel Kalevski

Welcome to my blog post about improving game performance through the use of Object pools.

As a game developer, it's likely that you've had to deal with the problem of instantiating a large number of objects for a specific class, such as particles with a short lifetime that need to be destroyed. One of the challenges of this type of game logic is that JavaScript's model is based on the garbage collection pattern, which means that developers do not have direct control over allocated memory.

Problem

When memory locations (variables) are marked as null, they are collected by the garbage collector and removed from memory. However, when the garbage collector needs to dispose of a lot of objects, it takes a lot of processing time, which can negatively impact the performance of the game.

In that case, if you profile the memory, you will see something like what is shown in the picture below

before

Solution

But there's a solution to this problem, and it's called the Object pools pattern.

The Object pools pattern is an implementation that helps to reuse disposed objects instead of creating new ones. By reusing objects, we can reduce the number of objects that need to be created and collected by the garbage collector, which in turn improves the performance of the game.

After using Object pools, you will get results like this

after

Phaser Plus Object Pools

class CreateGameObjects extends Scene {

onCreate() {
this.pool.register('myObject', MyObject)

// create object using pool
let turtle = this.pool.obtain('myObject')
this.add.existing(turtle)

// remove object from scene and retreive back to the pool
this.children.remove(turtle)
this.pool.release(turtle)
}

}

· One min read
Daniel Kalevski

Hi,

this is my first tutorial, so I hope it will be useful for all those who plan to start a new project using Phaser.

As part of a phaser-plus project I started recently, there is @phaser-plus/cli - a command line tool for creating and developing Phaser projects.

What is Phaser?

Phaser. is a free and open source software developed and owned by Richard Davey. You can visit their funding page and help them to make Phaser even better.

How do I make a project?

Before you start creating a project, you need to have NodeJS 16+ installed on your machine. If you already have NodeJS 16+ installed, you can create a project by executing:

npx @phaser-plus/cli init --template=phaser my-phaser-game

CLI Features

  • Simple setup
  • Hot module reload
  • Optimized production build
  • Support for Web workers

· 2 min read
Daniel Kalevski

Hi,

Welcome to my first blog post!

My name is Daniel Kalevski, Software developer passionate about creating games especially with Phaser. I started using Phaser before 8 years for creating "Point and Click" games.

Currently, I am proud of the large number of games I have created that are currently being used commercially, and I am also proud that after 8 years of using Phaser and developing games, I am about to release my first indie game.

What is Phaser Plus ?

I want Phaser Plus to be my contribution to the Phaser community as a way to thank the members for all the help I have received in the past years. My goals for Phaser Plus are to enrich the list of tutorials, plugins, and extensions for Phaser and also to simplify the process of developing games.

Currently, Phaser Plus offers a project creation tool, debugger, an extension for creating isometric games and a guide for building larger projects.

What is next ?

In the future, I plan to continue developing Phaser Plus and adding more useful features and tools. Some ideas I have for future development include:

  • Split screen feature
  • Tool for creating audio sprites
  • Utilities and helpers for common game features

I hope you find Phaser Plus helpful and that it makes your game development process more efficient and enjoyable. If you have any suggestions or ideas for future development, please don't hesitate to reach out and let me know!