The service is unavailable.

Many off-screen instances cause slow down

Discussion and feedback on Construct 2

Post » Thu Mar 07, 2013 11:30 am

I am working on a level editor where the plan is save the canvas arrangement to an array and then save the array.
But I haven't gotten that far yet to show any code.

The problem with my code is that I will push to the array:
"For Each Instance Order By Instance.Zindex ascending"
so that when it put them all back, they would be in the correct Zorder.
You would have to sort by X maybe, or make an instance variable labeling which column they belong to, and you could draw that column offscreen as your character approaches.

--I have a game that checks the FPS every couple seconds, and if it's below 25 twice in a row, it starts "destroying" extra scenery.

Edit: to clarify the column idea, your character is touching a block that's instance variable says it is in column 5. So if column 2 and column 7 aren't drawn, draw them. (if headed right, column 2 would have been drawn already, and column 8 would get drawn.)
Then you would also destroy any Column 1 and column 9 instances.Paradox2013-03-07 12:13:30
Posts: 907
Reputation: 41,515

Post » Fri Mar 08, 2013 8:59 am

@Paradox, I'm looking forward to it:)

Some progress here:
I have tried solved the issue by dynamically destroy instances off-screen and re-create them in appointed position. But ironically this way seems cost more cpu because of lot of looping.

So I tried to cut off instances to 300-400, it looks slightly worse, but the framrate is acceptable now:)
Posts: 94
Reputation: 2,089

Post » Sat Mar 09, 2013 11:49 pm

I have had similar problems in some of my games when there are large scrollable levels. It can be seemingly quite random slowdowns in framerate that then pickup back again. Haven't really been able to totally pinpoint the source, as sometimes recreating the level and changing object layers has resolved it.

Seems mainly related to collision detection. For instance, a bullet object that has a collision event on a large scrollable level has caused massive slowdown in chrome/ie10, but when I get rid of this event, the framerate is back to normal.

Are collision events being calculated for all objects in a layout or just visible ones? I have tried coding it so that it is only seen via " is in layout" but it didn't make much difference. Are collision events more efficient when they are on the same layer, or is this irrelevant?zendorf2013-03-09 23:51:02
Posts: 108
Reputation: 1,899


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 4 guests