Quick follow up on this for anyone with this problem in the future.
I found the cause of my gradual slow down the longer the game was running:
Objects being created but not being destroyed when leaving the screen.
I made several mistakes where objects (or pinned objects) weren't being destroyed when leaving the screen and being allowed to 'live on', causing degradation in performance over time.
The main reason I'm writing this follow up is to highlight a method I used to get to the bottom of the issue and find the problem sprites.
It's hard to debug this in most games, where you're not spawning a huge number of objects at a time. You'd need to leave your game running a long time to see where the game was slowing down.
One good way around this is to create tests in your game where you take each object at a time, and spawn that object many times. I spawned one object every 0.01 seconds using the Every X seconds event.
Then use debug layout and check that the objects on screen count reaches and stays at a stable level. IE as it's not going up - and objects are being destroyed just as fast as they're being created.
If they're being destroyed properly upon leaving the screen, or the layout, the count will remain stable.
There's several handy ways to destroy objects that leave the screen on Construct:
- Checking their position on the layout
- Using has left layout behaviour
- Using the inverted 'is on screen' event
1) If your game is slowing down over time, check objects are being created and destroyed properly.
2) Test each object separately.
3) Create a simple test in your game to spawn HUGE numbers of each object you are testing to save testing time.
4) Check the OBJECT COUNT in Debug layout