Today I resolved some issues I had with lag on my game by replacing the layering system I was using. As well as replacing my platforms with an easier to manage methodology.




I removed “var graphics = this.add.graphics();” as the new platform system uses a provided image reference to draw the platform, rather than a shape. The platforms group allows new platforms to be easily created and adjusted with the built-in class methods.

As you can see above, I have removed the constant drawing of the background and the platforms. This is because it caused immense lagging and frame rate reduction when ran, as well as being an incredibly inefficient system. Instead, the code now updates the forest image positions and the platform positions every frame. Furthermore, I removed my jump calculations and instead coded the jump animation to play once upon the player starting the jump.
The result is a game that has higher performance and new platforms with collision functionality: