Low frame rate when tweening large sprites on native mobile

Hey folks,

I’m rendering a large scene using a Sprite containing multiple other Sprites.
My intent is to scroll the scene by tweening the position of the containing Sprite, but that appears to be quite slow on native Android and iOS (around 20fps).

Is it simply not a good idea to animate large Sprites? Is there a smarter way to achieve view scrolling?

Thanks,

- Michael

Are you using cacheAsBitmap, filters, or sprite.graphics?

I’ve tried with and without cacheAsBitmap (with is much slower) and I have no filters. I am using sprite.graphics to draw a bunch of static things in the background, though. After removing them, mobile runs at 60fps!

This is good news, but it leaves me wondering how I should render 2d polygons, if not with graphics.drawPath.

Advice?

Solved!

I split everything requiring graphics.drawPath into a separate Sprite for which I set opaqueBackground = 0xffffff and cacheAsBitmap = true. Now everything’s silky smooth.

Thanks for the help. Your question set me on the right path.

cacheAsBitmap causes things to be written to a software surface. If it does not have it’s cache invalidated, this can help improve performance, but if the object needs to get redrawn, it can slow performance a lot. Bitmap filters imply cacheAsBitmap, so same story. sprite.graphics draws to a software surface, so using a lot can eventually lead to overdraw if you are not careful.

We have plans to optimize simple cases (such as drawRect) using hardware rendering instead to help lighten things up, but opaqueBackground works for that too :slight_smile: