**This is an old revision of the document!**

This page is a draft for good rule to apply for optimize a game.
This is a draft in progress @Bouh

-How objects are managed by GD5 (object variables, behavior, rendering) -What optimizations are already do by GD5 (GD5 tell to PixiJS to not render the object)

Search other thing to say about this…

-Delete the unused object (see the behavior “Destroy outside screen behavior”) - Disable the behavior on objects unused or off screen. -Use the condition “Once…”

The optimization of a game is important, a good optimization will allow a game to work faster, and it will be more fluid.

GDevelop 5 gives you total freedom in events, which can be awesome but also cause very costly for the processor where the game is running.

It is important to know that are events and there are each called once per second.

For example for a game at 60fps if you have this action then in this action will be executed 60 times in a second.

Trigger once

Tigger once is a condition, this allow to run the actions ony once, for each time the conditions have been met.

Let's take an example where I want to create an object every time I click. I'll show you the wrong way and the right way to do it.

What i want : When i press the mouse left button i create an object called “MyObject”. What i get : When i press the mouse left button i create multiple objects called “MyObject”.

This is bad because when you press the button your finger is on button during a short time maybe like 0.3seconds. During this time the event can be called multiple times then the object is created more what once.

For fix that we need add the condition Tigger once in the condition.