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

Get help using Construct 2

Post » Wed Jun 18, 2014 2:30 pm

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!

Image

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

Image

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

Image
Last edited by ForgedByHand on Thu Jun 19, 2014 12:05 am, edited 1 time in total.
B
7
S
1
Posts: 27
Reputation: 511

Post » Wed Jun 18, 2014 4:32 pm

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.
B
20
S
7
G
1
Posts: 221
Reputation: 2,077

Post » Wed Jun 18, 2014 5:07 pm

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.
B
7
S
1
Posts: 27
Reputation: 511

Post » Wed Jun 18, 2014 5:09 pm

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
B
42
S
17
G
17
Posts: 2,247
Reputation: 17,471

Post » Wed Jun 18, 2014 5:17 pm

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.
B
7
S
1
Posts: 27
Reputation: 511

Post » Wed Jun 18, 2014 5:29 pm

You can also try using sprite text instead of the text object, it should be faster.
Moderator
B
95
S
34
G
33
Posts: 3,007
Reputation: 27,876

Post » Wed Jun 18, 2014 5:39 pm

Glad it helped... Good rule of thumb when making mobile games...is 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!
B
20
S
7
G
1
Posts: 221
Reputation: 2,077

Post » Thu Jun 19, 2014 12:07 am

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.
B
7
S
1
Posts: 27
Reputation: 511


Return to How do I....?

Who is online

Users browsing this forum: worm1, Yahoo [Bot] and 22 guests