How do I stop my game from lagging massively? (Solved)

0 favourites
  • 8 posts
From the Asset Store
five golem elements Sprites Sheet.Best for enemy or villain game characters.
  • This is a weird one, I've put together a simple game which works perfectly on desktop, but when I test it on a mobile platform using the wifi debugger I find that the game lags massively under the start and end conditions.

    During the game performance is fine, I can get 55 fps on Crosswalk, but during the start and fail conditions I get 6-12 fps!

    The game is physics based but at no point does the physics engine demand more than 2% of cpu time.

    Checking the profiler shows that drawing calls increase during the start and end conditions - on mobile platforms they take up 93% of CPU time, but essentially theres only one animated sprite on screen & 7 tiled background distributed through 7 layers, I'm scrolling these infinitely so they're pretty tiny.

    Can anyone spot anything in my event sheet that might be causing the system to make lots of draw calls? The games so simple I have no idea what I could have done wrong!

    It lags on startup when its loading the assets which I kind of expect but as soon as the timer throwball completes the fps shoot up

    Then as soon as the fail conditions are met the fps fall off a cliff

  • First thing i would do i move those Set Text out of the every tick condition and put them in an every 0.5 sec - 1sec. I Notice a massive loss of performance updating text on every tick on mobile.

  • That made a HUGE difference! Theres still a slight hitch when an iframe updates but that could well be to do with my staging servers crappy response times. Definitely a move in the right direction. Thanks very much.

  • A better thing would just have the Set Text when needed, for example, when score is incremented (+1),

    Also, Did you try removing the iFrame, refreshing and setting up the iFrame could be the cause ... Either way, I don't see anything else

  • I'm not too fussed about the lag caused by the iframe as it isn't really noticeable, but the fps hit I was taking from the set text call was.

    I'll set up a function I can call for the score update. Thanks for the tip.

  • You can also try using sprite text instead of the text object, it should be faster.

  • Glad it helped... Good rule of thumb when making mobile try to avoid doing anything on every tick if you can that isn't specifically related object movement. Set X,Y any time you want cause those are movement but things like conditional changes like when to change animation (if i can get a way with it) or spawn sprites and stuff like that I put in an every 0.nth(sec) to squeeze as much juice out of the app as i can for movement and actual animations that are currently playing. sure my smoke takes 0.1 second to show up after a hit but the player doesn't notice it and i don't waste CPU every tick checking if its time to show it. I want movement as smooth as possible always so some things get sacrificed. Good luck!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Once I removed all text objects and replaced them with SpriteFont+ objects... Perfecto!

    Plus it means less faffing around with webfonts now so makes life easier for me. Well chuffed!

    Thanks for the tips toublesum, I'll have a poke around in my events and see where I can put them into action.

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