Optimizing objects
-
@Stanica I had this same issue with FPS dropping. The answer lies on this. Are you constantly spawning new items? Or are all 60 items already in the game once you hit start.
-
All objects are rendered at the beginning of the scene. I don't have any loops running in the background either.
-
@Stanica this is what helped me. You mentioned that you had some bg objects which is good. Be sure to make all objects that don’t have any collisions and set them as a background object. Also try adding all your coding into one main object. For example create an empty label and call it Game Logic. From there add all your coding to that label. That alone should help with performance issues drastically. It’s a pain to do as it’s much easier to have all the logic within the main object. But for some reason this helps greatly.
-
@SplitMindGaming if your game has a main menu right before it starts. Preload the next scene before hand.
-
@SplitMindGaming That's exactly what I've done. The greenish path in the picture is a bunch of background objects without collisions. Only the salmon colored sections are walls. Most of my logic is inside an empty label called Game Logic. If I pan the camera so that a smaller number of objects are in view, the FPS jumps back to 60 so I suspect it's the collision masks that are causing the slowdown.
-
@Stanica yeah that could be the cause also. 60 objects is a pretty big number imo. My main scene on my game has at the most 30 items and I was already dealing with FPS issues as well. My only other recommendation is to possibly recycle those images on view. For example have only like 20 objects on scene and constantly move them to the players view.
-
@SplitMindGaming Unfortunately, the course is procedurally generated so I can't do anything fancy like render only the part of the course that's currently visible. If I could set a seed for the random number generator then I might be able to....
-
How large are your graphics? and how much transparent space is there? Transparency really kills performance. You should try to crop as tightly around your objects as possible.
-
You should be able to have more than 60 objects out without having lots of lag. If you want to you could upload your project for me/anyone else to look at and see if they can help find causes of lag (my iPad is expert at this cause it's already laggy 😛)
-
@Murtaza said in Optimizing objects:
How large are your graphics? and how much transparent space is there? Transparency really kills performance. You should try to crop as tightly around your objects as possible.
Each sprite is 2048x2048, scaled down to 10% with no transparency.
@Aidan-Oxley said in Optimizing objects:
You should be able to have more than 60 objects out without having lots of lag. If you want to you could upload your project for me/anyone else to look at and see if they can help find causes of lag (my iPad is expert at this cause it's already laggy 😛)
I might take you up on that if I can't find a suitable fix.
-
@Stanica That's massive. If you can, scale down the actual image size so that your objects can exist at 100%. You should get the same quality images but way less lag.
-
@Aidan-Oxley I'll try that or increasing their size to 20% so there are fewer objects on screen at once.
-
@Stanica If your image editor allows it, scale your sprites down to 205 × 205 pixels, and then replace your objects with those and scale them to 100%. They should look exactly the same, I think. Yeah having fewer objects can help a bit, like if you can combine some tiles that don't do much from 2 or more separate objects into one, especially if they are background objects that don't move.
-
@Aidan-Oxley 👍
-
@Stanica that has to be the problem right there. 2048 x 2048 for each sprite. Yeah I always try to make each of my object the exact size it needs to be without having hyperPad constantly tell the code to resize the image. The less instructions you can have hyperPad make. The better. Scaling it down to the actual size. Removing all the empty space borders. If you have photoshop the best way to really crop it perfect is to to go to file. Then export to layers. This will crop each image perfectly.
-
Yeah the image size is definitely affecting your performance.
As the rest have suggested, try making it the actual size you need. For something like this that will be used to create a procedurally generated level I would avoid going beyond 256x256 pixels.
-
Thanks for the tips everyone. Managed to fix all performance issues by decreasing the size of my assets!