How do I optimize performance?

0 favourites
  • 8 posts
From the Asset Store
Firebase: Analytics, Dynamic Links, Remote Config, Performance, Crashlytics on Android, iOS & Web Browser
  • 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.

    [attachment=0:1c2cbroa][/attachment:1c2cbroa]

    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.

  • 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.

  • 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.

  • 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?

    [attachment=0:2ctv51ow][/attachment:2ctv51ow]

  • 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.

  • 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.

  • 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 )

    [attachment=0:n8er5wc3][/attachment:n8er5wc3]

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)