[Solved] Why is my game lagging?

I have made a scratch ticket game. And all the grey you see, are all individual small objects.

If i preview the game on the gdevelop editor, everythings moves smooth.
But on the android app it laggs enormously.
How can i optimize this?

Example :
https://youtu.be/VhKwnsX8xO4

Thank you in advance!

1 Like

On Phone games are always more laggy, search “optimisation phone” on the forum to find many tips on how to improve performance.

The problem is that you are checking collision with hundreds or thousands of objects every single frame at once.
The only way to improve this if you divide your lucky card in to zones and use different objects to cover it for each zone and check which zone the player touching the card and check collision only with that few objects that is in the same zone as the player (touch).

If touch is in zone1
If touch is in collision with zone1object : delete zone1object

if touch is in zone2
if touch is in collision with zon2object : delete zone2object
…etc

You can also further optimize it by picking only 1 object at the time to check collision with by using the pick random object event.

touch is in zone1
pick a random zone1object
touch is in collision with zon1object : delete zone1object

But then the scratch experience may not going to be smooth because maybe you are not going to check collision with that very instance the touch is colliding with so you want to experiment with this to find how it works best.

1 Like

Thanks for your answer. I will try that. How do you suggest to make a zone?

You can check the X,Y position of the touch or you can also use invisible objects to cover each zone to check collision with.

Thank you very much. Works much smoother now.

1 Like