Issue with side scrolling game

Discussion and feedback on Construct 2

Post » Mon Mar 17, 2014 9:06 pm

We've been working for about two months on a basic side scrolling game, with character movement up and down and parallax in the background.

However, now that we are at a demo stage and started testing, we found issues with the scrolling movement. We tested on the following browsers: Chrome, Firefox, Opera, Explorer and Safari. In chrome, the game runs fluidly, with up to 60 fps and no issues at all, but on all the other browsers, there are "stuttering" issues. We can notice slight stutter in the parallax effect and any object that we place in the background or foreground, as if there is a frequent micro delay.

After extensive research and reading through several threads on these forums, we tried some performance optimization tips, but with no positive results.

Next, we registered with Ludei, as we also saw in their promos that cocoon solves most performance issues. However, after going with cocoon and testing an android version on a Samsung Galaxy cellphone and Google Nexus 7 tablet, the same stuttering issues are still present.

Finally, we stripped the game down to almost nothing, just the character, a static background and one image of a plant in the foreground, and the same issue persists. You can check the stripped-down version at the following link (http://www.tenbolts.com/fish_game).

As an additional test, we went back to the template that comes with Construct 2 (flying along) and we noticed that the same stuttering is present there, too. You can check by exporting the flying along template as is to html5 and running in browsers to see that the green blocks at the top and bottom do not have a completely fluid movement in all browsers, except chrome where it runs perfectly.

This has us really baffled and we are at a dead end on how to solve this issue in order to have a fluid running game.

Any thoughts and suggestions will be much appreciated.
B
24
S
6
G
2
Posts: 22
Reputation: 2,021

Post » Tue Mar 18, 2014 10:23 pm

Yes, I am experiencing the same stuttering problem that you mention on my own tests, with a platforming game in mind. I only tried Firefox and Chrome on PC though, no other devices, but since even a very simple scene with a few events seems to cause stuttering, my guess is that less powerful devices will render similar results.

In my experience, Firefox delivers almost half the frame-rate of Chrome, the second being almost constantly fixed at 60 fps. Almost. And there I believe lays the problem:
For some reason, every few seconds Chrome drops one or two frames below 60 and that results visualy as stuttering. I don't remember if that was always the case with Construct 2, I haven't using it lately and with all the stuff that had being added and with internet browsers updating all the time, I feel kinda lost.

In your game (by the way, I really liked what I saw, great job!) the stuttering is most noticeable at the beginning when the scrolling speed is low, after a few speed-ups I couldn't really notice anything.

I feel like this problem needs to be confirmed and if so addressed as a priority, in fast moving games with delicate controls it really distracts the experience.
composer - multimedia artist
www.eli0s.com/en/
B
69
S
27
G
6
Posts: 1,146
Reputation: 10,379

Post » Wed Mar 19, 2014 12:42 pm

Rendering perfectly at 60 FPS means regularly hitting v-sync intervals in the monitor with very high precision. At 60 FPS these come about every 16ms, which is a pretty small amount of time to be hitting accurately. I don't think this is specific to Construct 2 or HTML5, because our old DirectX-based native engine had the same problem. I think sometimes the OS does some background work or the timers just aren't quite accurate enough and you drop a frame. In Javascript there is the added problem of garbage collection, but modern collectors are pretty good (as you note in Chrome it's nice and smooth).

I don't think there's anything that can be done about this to totally resolve it. Still I think it's a fairly minor jump if it's just one frame that's dropped, and overall the motion is pretty smooth.
Scirra Founder
B
403
S
238
G
89
Posts: 24,653
Reputation: 196,143

Post » Wed Mar 19, 2014 3:31 pm

I was doing some testing along these lines a month ago and figured it was mostly garbage collection to blame.

Things did seem to improve when I made as little garbage as possible.

What I did was create all objects before the game started, and never destroyed ANYTHING. I kept everything I wasn't actively using just off screen, then moved them into position when they were needed, and moved them back off screen when they had been "collected". That way, while the game was running, no new memory was being allocated to create objects, and none was being released to destroy them.

I didn't test on very many devices, and haven't had time to dig any deeper into it since then, but it definitely seemed to help!
B
99
S
35
G
20
Posts: 438
Reputation: 17,910

Post » Wed Mar 19, 2014 5:42 pm

tenbolts wrote:We've been working for about two months on a basic side scrolling game, with character movement up and down and parallax in the background.

Any thoughts and suggestions will be much appreciated.


I was working on a game that had 2-3 levels of parallax that would freeze the game on Firefox at the beginning (1-2 seconds in), but not freeze on Chrome nor on the IP server mobile testing. Then after refreshing Firefox, the 2nd play would not freeze. I just assumed Firefox had HTML5 issues. Since yours is a Tap game, probably for mobile, have you tried setting up your C2 to test on your local IP server and use your mobile device to browse in?
B
9
S
1
Posts: 18
Reputation: 511

Post » Wed Mar 19, 2014 7:16 pm

Thank you for all the responses. Sad to hear that it is such a difficult problem, though, especially with platformers. We will be trying out the suggestions provided by AllanR and lokken, hope it helps.
B
24
S
6
G
2
Posts: 22
Reputation: 2,021

Post » Wed Mar 19, 2014 8:33 pm

@AllanR - the engine is already very carefully designed to minimise garbage creation in all parts, to the extent that creating and destroying whole instances does not allocate any memory, it recycles previously created instances. So keeping objects offscreen should not be necessary, even if you destroy them the next instance will be created from the same memory as the last destroyed one.
Scirra Founder
B
403
S
238
G
89
Posts: 24,653
Reputation: 196,143

Post » Wed Mar 19, 2014 11:05 pm

@AllanR an interesting approach you went literally the opposite way I did on one of the games I'm making (where I was generating too many objects and had to destroy them all)... maybe recycling the objects like you did may help with the stuttering on my game but i'd have to re-"code" most of what I'm doing. Maybe I'll try using that alternative for next game. :)

@Ashley - update - hmm... so what could cause the stuttering. I'm using 2 BG's going back and forth with them, and making 4 platforms while falling (which is causing the player to jitter a bit ocasionally) I'm experiencing the same stuttering in cellphones too.
Freefall Bird
B
47
S
9
G
5
Posts: 281
Reputation: 5,803

Post » Wed Mar 19, 2014 11:13 pm

@tenbolts btw your game looks very nice and so do the layouts
Freefall Bird
B
47
S
9
G
5
Posts: 281
Reputation: 5,803

Post » Thu Mar 20, 2014 12:08 am

I agree, tenbolts, your game looks great - and runs pretty smoothly on my iPhone 5.

Ashley, well, that is good to know, and doesn't surprise me too much - because everything else in Construct2 is "very carefully designed".
It is possible that my results were more imaginary than anything else. I started with someone else's project that was not working very well, and I cleaned up the code, added parallax scrolling, completely changed the way the background was looping, etc. By the end it was working much better - but still not perfectly smooth. Some day I want to try Cocoonjs (and other wrappers) to see how much that helps (or not)...
B
99
S
35
G
20
Posts: 438
Reputation: 17,910

Next

Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 2 guests