[SOLVED] My game for mobile runs very slow

I am trying to make something like match 3 game, i havent finished it yet, but it runs really bad on mobile. I need help. Here is the code.

I’ve had a quick look and say that the problem is caused by how your events are coded. WIthout knowing the exact function of what is going on, it’s difficult to say exactly which events are the culprit, but I did notice you have many, many for-each events happening, and these can be extremely taxing on the game, as each one of these will be running multiple times per frame unless conditioned otherwise.

To pinpoint what sections are affecting performance the worst, I would recommend dividing up your events into groups, so when you check the profiler, you can see which groups of events are using the most processing power.

Hope this works as a good starting point.

A few things sprang up straight away (and I see @convictedweirdo spotted some of the same) :

  1. You haven’t got a “At the beginning of the scene” condition for the hiding of objects, setting of wallpaper and your camera positioning. They all only need to be done once, because they never change during the game:

  1. You have a lot of repeats. And I mean a LOT! My understanding too is that repeats are resource hungry.

  2. Put your objects with square in the name into a group, and refer to that group, and not each object individually. See the previous screen shot as well as:

I’ve had a go at tidying up the code, and removed a lot of your Repeats. The collision between squares could be done differently, but that’s for another day.

Here’s a download link to the .json game file. Download it, put it in your project directory (make a backup copy of the original first). Try it and see if it runs faster on the mobile.

You helped me a lot! Thank you! But there is a problem, after 5 minutes of playing cubes start to get on each other…Not always, but it starts to happen. I don’t understand why, why it is not happening from the beginning.

Is that when they are sliding and don’t stop in time? Or is it when they’re next to each other and you can move them on top? See if there is a pattern to the behaviour.

When they are sliding and don’t stop in time. I don’t see pattern for this. Maybe I need to change stopping system. What else I can do for that…