How do I optimize performance?

Get help using Construct 2

Post » Mon Mar 24, 2014 10:32 pm

I feel like I am on the borderline of what I can put into my game now, as I experience some quite significant drops in fps from time to time. It seems to be running in a smooth 60 fps on my desktop (however it dips a bit during debugging), but a bit below this on mobile (I'm running on a Nexus 5, so on slower hardware it would be even worse).

The thing is, I don't think I have a lot of objects, big images, physics, collision checks etc. I'm trying both with sampling set to point and linear, but with no real difference.

Performance.png


I am using a single small black sprite as a building block (which I resize and duplicate quite a lot). Could this be a problem? Is it better to create my levels as one image instead of putting smaller images together into a bigger level?

Any input would be helpful. Let me know if I could provide more details.
You do not have the required permissions to view the files attached to this post.
B
14
S
3
Posts: 123
Reputation: 1,571

Post » Mon Mar 24, 2014 10:39 pm

Have you tried destroying your objects outside of layout?(depends on your type of game tho)
I had a similar issue some weeks ago. I was using a template and forgot to switch my signs so my objects were not being destroyed as they should... ended up having 300++ objects and increasing them with time. when i fixed it it was a steady 40-43 objects all the time. which greatly increased my performance.
Freefall Bird
B
47
S
9
G
5
Posts: 280
Reputation: 5,781

Post » Mon Mar 24, 2014 10:55 pm

My grain of sand, according to my own mobile struggle is;
1) no to HUGE objects. (even empty space in a sprite needs to be calculated for rendering, so it eats up processing power anyway)
2) NO to too many collision checks
3) no to too many objects doing too many things at the same time
4) no to unnecessary workaround processing. You need to think up that efficient formula every time.
5) Separate things into different layouts if you can.

the 4th point is really important to me. I'll give you an example from my own experience:
I made a game a while back, and needed to show the final score after the game ended. and i wanted to be cute and re-count it in real time. For this i had made a formula so it didn't take too long to count when the score was too high. so i told the game to add a sqrt(totalscore)*3 to the final score counter. It did work, but the game had to calculate this for every time it added the fraction to the score.
Eventually, since it wasn't very efficient, I added a variable to store that fraction given by sqrt(totalscore)*3. i just calculated it once, and then i added the variable, instead of the formula, to the finalscorecount thing. and the fps went from 5, to 60 in a heart beat. and i was so happy.
B
43
S
12
G
6
Posts: 446
Reputation: 6,802

Post » Tue Mar 25, 2014 7:07 am

It's a platformer. I'm destroying the few objects that I can think that should be destroyed, so not sure that's the problem. I have a few variables (a timer/clock, one for number of deaths (add 1 when outside layout), number of kills (add one every time an enemy is killed) etc). Most of them work like this: when collision between player and object, add 1.

I don't think I have a lot of "huge" objects. My backgrond tile is something like 2*1024 I believe. Then I have some layers between the background and the main layer with tiles consisting of 524*256 images. For foreground I try to reuse some background sprites, only resized.

But are you saying 357 is a lot of objects? What about 7350 collision checks? How can I reduce this?

Just a very simple example from my game: I am creating my levels using mostly a single, small black square that I copy and resize to create something like the below (separate sprites indicated by red lines). Do you think it would perform better (less collision checks perhaps) if I had created it as one single, bigger sprite?

test.png
You do not have the required permissions to view the files attached to this post.
B
14
S
3
Posts: 123
Reputation: 1,571

Post » Tue Mar 25, 2014 12:39 pm

The estimated CPU is very low, which suggests it's bottlenecked on the GPU (i.e. events/collisions are nothing to do with it). Often this is the fillrate (too many layers/large objects). It is very hard to offer any more help without seeing the actual project.
Scirra Founder
B
387
S
230
G
88
Posts: 24,249
Reputation: 192,450

Post » Tue Mar 25, 2014 1:39 pm

@Ashley - I remember reading long ago that the number of layers was unlikely to affect performance. So is that not actually true? I've had a bit of mystery lag lately but always have a rather high number of layers, so hopefully this could be an issue I could solve.
B
28
S
8
G
5
Posts: 429
Reputation: 6,997

Post » Tue Mar 25, 2014 3:01 pm

Thanks for you input guys, feel free to take a look.
(I trust I won't be seeing a full version of my game on Play Store in the next couple of days :P)

RUN.capx
B
14
S
3
Posts: 123
Reputation: 1,571

Post » Tue Mar 25, 2014 4:30 pm

@Tobye - Performance tips: "Number of layers usually has no effect, unless most of the layers have changed their opacity, have effects applied, have a blend mode other than 'Normal', or use 'force own texture'. However typically there is no performance impact from using multiple layers with default settings."

I can't immediately see anything obviously wrong with the project, except it has a fair bit of overdraw. TBH 50 FPS isn't bad for mobile.
Scirra Founder
B
387
S
230
G
88
Posts: 24,249
Reputation: 192,450


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 10 guests