Flatten Display Group

I have submitted this as a bug feature request as suggested. Case #7524

Hi everyone, we desperately need a way to flatten a display group into a single image *on all devices. Our levels when fully constructed can have quite a few images inside one screen, and this kills the frame rate. Many of our level items are actually static within the level area, so flattening certain images is an option for us.

Flattening the image vastly improves frame rate. In one of our levels there are 160 display objects (images,shadows,masks) in one level, and when flattened, reduces to… *drum-roll*… 1! This has a massive effect on performance.

We’re currently making use of display.save() with iOS which works impressively well, but as stated in the docs this is very limited on Android devices. Plus it takes a little extra time on the device to write to disk and load back from the disk. We don’t plan to release to Android until after iOS, so we thought a request now, just might mean a the feature will appear by the time we need it.

Basically, we would like to be able to do this:

[code]local flattenedLevelBackground = staticObjectsDisplayGroup:flatten()

staticObjectsDisplayGroup:removeSelf()[/code]

The display group would be flattened, and the new image returned as a new display object (instead of writing to disk).

We think this would benefit anyone where their levels involve a significant amount of display objects which are static.

Thank you kindly for your consideration :smiley: [import]uid: 35618 topic_id: 13884 reply_id: 313884[/import]

This goes along with the dire need of a display_object.copyPixelsTo(another_display_object)…

or something like that.

Its just a basic painting feature that takes pixels from A and paints them on the texture of B.

I second the motion! [import]uid: 8541 topic_id: 13884 reply_id: 51052[/import]

+1

Great idea! I could see this having a HUGE impact on performance in my own game.

How would something like this handle a ‘flattened’ display group that was bigger than the maximum size of a device texture? [import]uid: 9422 topic_id: 13884 reply_id: 51157[/import]

+1 [import]uid: 19626 topic_id: 13884 reply_id: 51160[/import]

@XenonBL, for now as we’re using display.save, we have our own custom function which accepts the dimensions of the area within the display object which we want to flatten. Most of our levels are one screen, so there’s no issue with those, but some are larger. In these cases, our flattening function moves the display object around to grab multiple screens and then sews them together in a returned display group.

But yes I agree, if this feature was to be added, it would definitely have to support display groups bigger than the visible screen. [import]uid: 35618 topic_id: 13884 reply_id: 51183[/import]