How do I make my game stop lagging?

0 favourites
  • 12 posts
From the Asset Store
five golem elements Sprites Sheet.Best for enemy or villain game characters.
  • Hi, I'm currently making a game for android with Construct 2. I have the latest beta version of construct, and I wrap my game with Intel xdk/crosswalk (latest version)

    I have read everything there is about optimizing my game for mobile, followed every tip and trick to make my game stop lagging, but cant figure it out.

    Its a simple autorunner type game where the layout size is 50000 x 720 px and all objects are placed on the layout on start.

    I tried reducing 50000 to 5000, but no change.

    The main game layout has about 140 objects (many instances of same object), and only about 10 of them has collisions enabled.

    I' ve tried to delete almost all of the objects, but my framerate doesn't really change.

    I've also tried disabling most of the events, disabling animations, and all every tick events.

    I use Spritefont and not text object, and have no huge sprites on layout.

    The game shows fine in internet explorer, with an almost steady 60fps, much better than the 30fps in chrome.

    As stated above, I wrap my game with intel and crosswalk.

    In the Intel preview window, it runs smoothly, but not on mobiles.

    I'll give more information if needed, and hope someone can help me with this.

    Regards David

  • Some questions:

    • What mobile have you tested your game on? (Specs required)
    • How detailed are your images?

    Some suggestions:

    • Don't put all object at once, but let them create before they should enter the screen and have them destroyed after they left the screen.

    To get proper help, I would suggest to attach the capx of your game. Then some experienced C2 users can have a look and can tell you what may cause the most problems.

  • A while ago, I solved a similar problem in Chrome disabling WebGL support. Maybe it help at least in chrome... XD

  • It's hard to say what the issue is, without having seen your code. I began using Construct 2 only 4 days ago, and after having made my initial game, performance was great on iPad (4th gen) but sucked on my iPhone 5. Especially if I increased my particle count (my scene spawns particles everytime a mouse button is pressed).

    And so began the optimizing...

    What I found - I hope you can find some of it useful:

    • Enable WebGL; iOS 8 will have WebGL, and it's MUCH MUCH MUCH faster than Canvas in all respects.
    • Avoid using new layers unnecessarily; blend objects into the same layer if possible.
    • Remember to destroy your objects/instances.
    • If you have stuff that rotates, try to remove the rotation.

    In the project settings:

    • Change sampling from linear to point; this gives a HUGE performance boost on mobile
    • Set pixel rounding to "On" - this can also give a big performance boost

    Last, try and test your project if you resample everything to fit 500px height. Maybe it's fast for you to do this check - if not, just use some dummy graphics with lots of details and colors, and basic scrolling behavior. This should give an indicator if it's worth pursuing this path.

  • Sorry for not replying sooner, and thank you all for your replies.

    I still can't figure this out, so I attach the capx here , and hope someone can help me out with it.

    Really appreciate the help

  • I cant open your capx because you heve "Move to" "Pause" and "Admob ads" Behaviors, but I think that your problem is your movile device or your browser is not fully html5 compatible

  • first 50000 or 5000 is big , you are working on autorunner you don't need that layout size , and 140 object is too muc , read the tips below there is some tips that you might not finde in the performance tutorial :

    • manually make your collision polygons and reduce the points if possible.
    • don't make very big objects , i know when you are a begginer you just drop 2000x1000 image to be a backdround

    just split it for example the background for the sky used a tiled background using small 32x32 single color image.

    and the backgrounds element as sprites for examples the trees and clouds and moutains each one of them in a sprite , that would be usefull to make parallax too to make the game looks nice.

    • reduce the loops and timed events as much as you can , when you know the score will change only when action happens for example player passes an obstacle , there is no need to make everytick set text....that uses a lot of the devices resources with no need.
    • if you need an object with 64*64 size don't make 256*256 then scale it down in the editor thats not helpful to save the platform resources.
    • try not to make more than 20 sprites in a single layout. if you need something to be used in another layout don't make another oobject just use that one, to minimise the number of used assets and the app size and the loading time.
    • don't use text object use sprite-font instead.
    • some proprities are helpful , like pixel rounding , enabling opengl , not clearing background, fullscreen scaling.
    • try not to make more than 100 event in eventsheet.
    • there are some very helpful features in C2 like importing eventsheet into other layout. and making groupes and functions when you don't need some event tests to happen yet just put them in a inactive groupe and activate them when needed the same for function when you need some some actions to happen in my conditions just put them in a fonction and call it when you need it.
    • use as less physic as you can you know it need a lot of mathematic calculations.

    and finally in export process don't forget to compress Png even brute compression isn't bad C2 suggests normal compression because it takes less times i didn't have problems with brute compression. and don't export to phonegap it kills the game performance.

    when you make project be sure to do all the above and i'm sure it's going to be fine.

    ohh i mostly forgot , don't forget to destroy objects outside of layout or when it not needed anymore. some people spawn a lot of objects like in autorunner the obstacles will randomly generated and keep moving until they leave the layout view. it's not helpful at all t have 100 ojects keep moving to the infinity , and the apps makes the calculations for them while you don't need them anymore.

    i hope this helpful , i'm sure you have read the performance tips in the tutorial but i have mentoned other things that might be very helpfull too.

  • Thanks for all the tips! its really helpful.

    What's the best solution for spawning objects in my game? Since this autorunner have to be the same level-layout every time you play. Should I make them all bullets and have a timer to create them, or is there a better way of doing this?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • What am I doing wrong?

    I deleted all my objects (the only ones left where the tiled background, the player, and ground)

    My game STILL lags!

  • Thanks for all hjelp, will post game when finished.

    David.

  • https://www.scirra.com/tutorials/4832/h ... en-layouts

    I though this trick will work for you

  • David, I know you don't have a C2 license, and I don't know if you're able to see the debug without it, but if possible, there will have a ribbon with what is consuming your resources and how much.

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