flame icon indicating copy to clipboard operation
flame copied to clipboard

Use `drawAtlas` for Particles

Open spydon opened this issue 2 years ago • 3 comments

What could be improved

We should investigate whether drawAtlas can now be used for particles.

Why should this be improved

It should be insanely much more efficient.

Any risks?

That it might not work properly on all platforms: https://github.com/flutter/flutter/issues/88220

More information

spydon avatar Dec 14 '22 09:12 spydon

Feel free to use my PRs to the simple_animations package as an inspiration: https://github.com/felixblaschke/simple_animations/pulls?q=is%3Apr+author%3Ayjbanov+is%3Aclosed

I believe https://github.com/flutter/flutter/issues/88220 shouldn't affect your use-case. That issue seems to be caused by our lack of targetWidth and targetHeight support in image Codec. However, particles can be created from pictures at desired resolution like this, i.e. there's nothing to decode.

yjbanov avatar Dec 14 '22 20:12 yjbanov

@spydon We use drawAtlas in Tiled via sprite batching: https://github.com/flame-engine/flame/blob/6fe517a0c20ac2508539f26766fc0f3c0f7a2ac2/packages/flame/lib/src/sprite_batch.dart#L366-L374

jtmcdole avatar Jan 03 '23 16:01 jtmcdole

@spydon We use drawAtlas in Tiled via sprite batching: https://github.com/flame-engine/flame/blob/6fe517a0c20ac2508539f26766fc0f3c0f7a2ac2/packages/flame/lib/src/sprite_batch.dart#L366-L374

Yep I know :)

spydon avatar Jan 03 '23 16:01 spydon