flame-engine / flame

A Flutter based game engine.
https://flame-engine.org
MIT License
9.19k stars 899 forks source link

Use `drawAtlas` for Particles #2221

Open spydon opened 1 year ago

spydon commented 1 year ago

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

yjbanov commented 1 year ago

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.

jtmcdole commented 1 year ago

@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

spydon commented 1 year ago

@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 :)