- Sun 8 Jul 2018, 10:32
Are you sure the FPS is drop and it is not just a glitch with rendering?
How much the FPS drop exactly and when?
In general to optimize your performance, first thing you need to keep in mind is that every single condition is checked 60-30 times a second in GDevelop and you may want to avoid certain conditions checked that many times by putting them in to a sub-event and check something require less resources in the parent event because the sub-event going to fire only if the parent event was true.
For example, if you have buttons in your game the player need to press, first check if the mouse is pressed or touch is down and then in a sub-event check, if the mouse is over the sprite. This way you don't waste resource on checking if the mouse is over the sprite when it is not necessary because the sub-event won't fire.
An other example is collision checking. In case checking collision on something that is created and deleted dynamically in the game like bullets and enemies, you may want to consider to check if the number of sprites is > 0 and do collision checking on the sprites in a sub-event to avoid wasting resources on calculating collision even if the sprite doesn't exist.
You may also want to consider to add a timer and limit the number of times / second you are checking collision, it helps to avoid slow down because of frequency of collision checking but from my experience it is not always help. If the collision checking on it own cause lag, regardless if you are checking 60 times or a single time / second, it will lag when the collision is checked.
You also want to avoid checking collision with too many objects at the same time and you may want to pick a random object and check collision with that single random object only. As this condition will repeat 30-60 times a second there is a very good chance by the end collision is going to be checked on all of your sprites but only 1 at the time instead of 30 which can increase performance.
Finally, avoid using pixel-perfect collision checking, never use it. Doesn't worth it, in-fact from what I heard it is not even planned to be included in GD5 for that reason because it is a bad practice.
Optimization is a broad topic, you can find lot of very good and very long discussions about it if you search the forum.