Large sprites, tiled backgrounds, and performance

Discussion and feedback on Construct 2

Post » Mon Aug 06, 2012 12:01 pm

I have been working on a game and found that it was randomly crashing on iOS with cocoonJS. After a bit of work and emailed to an from Ludei they told me what the problem was. My game was using all the memory.

My sprites were way too big. We have a lot of detail done on large backgrounds so the tiled background option wasn't really feasible. Also, when I started working on the game, directCanvas from appMobi was just launched and that didn't support tiled background at all. Which in turn caused me to use sprites for everything.

At one stage I tried to cut up some of the larger images to see if it would improve performance, but it didn't. Little did I know that it actually had.

So now I am at a situation where I am going to chop up my images and manually tile them. But I have some questions that hopefully someone with some more technical knowledge can tell me.

Does tiled background perform the same as a sprite if there is only one "tile"? Or is it stll faster?

Is there a plugin to easily tile images?

How small should should my tiles be? 256 x 256, 512 x 512, or could I get away with bigger? My background is approx 3072 x 1024.

I don't mean to be lazy and not search the forum - I have actually done some searching and reading, but I was hoping to get feedback from people who have come to the same situation.

Thanks

superkew2012-08-06 12:02:10
B
22
S
7
G
3
Posts: 189
Reputation: 4,270

Post » Mon Aug 06, 2012 1:19 pm

Tiled background is exactly the same as drawing a sprite if it only shows a single tile. However it is vastly more efficient at drawing large areas of tiles.

Mobile devices have much more limited resources than desktops. It does not matter which engine or exporter you use if you have lots of large images - you will simply run out of device memory. You just have to design your game differently. The maximum tile size supported is 2048x2048 but bear in mind each tile that big will use about 16mb of memory.Ashley2012-08-06 13:20:14
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,468

Post » Mon Aug 06, 2012 2:00 pm

Thanks for the feedback Ash, if I cut a 2048 x 2048 image into 16 of 512 x 512 slices, would it then be better?

Is there another way to create a large type of layout? Or would it be best to try and flatten whatever I can into single images instead of layering?
B
22
S
7
G
3
Posts: 189
Reputation: 4,270

Post » Mon Aug 06, 2012 8:43 pm

3072 x 1024 is a large background. If large portions of your background aren't shown on the screen at all times, then you could save memory by having tiles sized small enough so off-screen portions of the background won't be drawn.

If your game background is large to be scaled down to fit on-screen, then you should consider lowering your resolution. Third generation iPads are only 2048 x 1536.bWard2012-08-06 20:43:51
B
19
S
5
G
1
Posts: 104
Reputation: 2,920

Post » Mon Aug 06, 2012 8:48 pm

Cutting up large images does nothing performance wise, if the same pixels end up on the screen, except maybe make it a little slower.

You should not design layouts as large single images. Make each part of the background a separate object (and a tiled background wherever possible) and build your background out of those objects. This will consume vastly less memory and allow for significantly larger levels.
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,468

Post » Tue Aug 07, 2012 8:52 am

Thanks guys.

Ok, so what ever is drawn on the screen is what is in memory. If I have an image that is larger than the screen resolution the entire image is put into memory even though only a portion of it is drawn. Is this correct?
B
22
S
7
G
3
Posts: 189
Reputation: 4,270

Post » Tue Aug 07, 2012 9:20 am

Just a side note. My window size is 960x720, but the layout is the big one.
B
22
S
7
G
3
Posts: 189
Reputation: 4,270

Post » Tue Aug 07, 2012 9:53 am

The whole game is in the memory.
B
134
S
65
G
16
Posts: 1,765
Reputation: 19,188

Post » Tue Aug 07, 2012 2:38 pm

@alspal is right, it's not just on-screen objects that are in memory. The entire project is in memory, even off-screen images, and even images on different layouts.
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,468

Post » Tue Aug 07, 2012 3:29 pm

@superkew
Optimization is a problem no matter which platform you choose, and gamedevs and artists are constantly trying to replicate, stretch and re-export the assets to make sure their project stays in the performance limits.

Take for example the gorgeous Rayman: Origins, or Braid. They look absolutely gorgeous, yet it's possible to achieve those results without a single 2048x2048 texture! Play (or watch videos) of these games, and study how they did it! :D

Some nice reference videos for you:
Aquaria level editor
Braid level editor

@Ashley I thought the assets were unloaded when entering a new layout. Time to simplify my main menu I guess :P
B
107
S
40
G
10
Posts: 456
Reputation: 13,202

Next

Return to Construct 2 General

Who is online

Users browsing this forum: anty21ro, nimos100, Yahoo [Bot] and 5 guests