Are spritesheets necessary?

I’ve just been fiddling around with OpenFL a bit more, and I decided to try a few performance tests.
Using the swf library, I loaded an asset with some 30fps character animations. In Flash, I couldn’t create more then 60 instances without the framerate dropping.
Exporting it as cpp for windows though I managed to get 250 without dropping a single frame! The load time to initialize each object is significantly longer, but that doesn’t bother me.

I was not expecting such an enormous difference.
I’m now left wondering if I should even bother with spritesheeting the old Flash project in question, as targeting flash is not a priority.
Are there any drawbacks?

I’m only interested in targeting Steam, mac and linux desktops, possibly PS4 and XBox One. So far I’ve only been exploring the confines of FlashDevelop on my Windows PC. I haven’t got a mac or Linux OS currently installed, how would I go about testing these platforms, would a simple OS emulator like VMware Workstation suffice? Also, does the swf library function on said platforms?

It depends on the images in question. You can get away with having small resolution images, but as you get more and more it can become less organised and also it means streaming more files, which can result in performance issues.

If you’re animating or creating tilemaps, I would recommend using spritesheets as it means you only have one BitmapData reference, which means less memory consumption. Although, that’s memory, but when your rendering from multiple BitmapData instances over and over again, to multiple Bitmaps or Sprites, that’s when framerate can get quite chaotic.

Ideally, you want to have as little BitmapData references as possible, and if you need an image, just copy the pixels from one of your BitmapData instances and place it into your bitmap as necessary. That’s probably the most efficient way of dealing with graphics.

1 Like

Besides the load time? None that I can think of. It sounds like the SWF library is pretty well optimized.

In Flash, yes. On other platforms, I’ve heard it’s very slow.

Flash is CPU-based, but we use the GPU elsewhere, so you’ll some operations (like copying pixels) that are more effective for Flash than elsewhere, but the SWF library (and underlying code) is consistent between the desktop, mobile and web platforms – so if it works on Mac (for example) it should work on Windows and Linux the same, and often iOS and Android as well without a hitch. (or that’s the goal) :slight_smile: