Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any kind of particle emitter on Android like iOS CAEmitterLayer for circle emitter?

My issue is difficult to resolve as of now.

I am supposed to develop an Android application alongside my colleage that does the same thing but on iOS.

At the end of the development, we are supposed to deliver two applications that do the same thing and look alike (be reassured, nothing like iOS guides-lines forced on Android and vice-versa) so that the experience is the same and immersive.

One of the top feature to provide, is a nice looking animation of a white empty circle that emits snow-like particles inside the circle. The circle can move via scrolling or simply bouncing/sliding animation.

So imagine a circle with a white border and white particles going off that white membrane. All those particles are drawn to the center and their speed base is variating (but no accelaration !). The fastest particles are suppose to "die" before reaching the center. Something that can easily be set via settings for lifetime and speed of course.

My partner, who is a junior like me, is using iOS' CAEmitterLayer and the results she obtained within a day or two is gorgeous and really close to what we are supposed to achieve.

On my side I am really struggling. Like her, I don't really have any experience in any animation and UI/UX. While looking for a particle generator/emitter on Android, I stumble upon this good-looking library : https://github.com/plattysoft/Leonids and it seems it can offer what I am looking for.

But I have a few unresolved issues using this library :

  1. I cannot or do not know if I can place emitters inside a circle ;
  2. I believe that if the circle, on which the emitter is hooked, is moving (scroll/animation) there is a strong possibility that the particles won't move with the circle ;

As I said, my iOS colleague resolved these issues. Even the moving part: we were talking with our manager that told use "what if the circble moves ?" and she immediately tried it in front of us. I was blown away...

She told me I should be looking for a way to contain my particles inside a container (makes sense ^^) and that my circle view should be clipped with layers so that the particles won't leave the circle especially if the whole thing is moving.

This is what I have achieved this thanks to the aforementioned Android library :

  1. I can emit particles, define their shape, their scale/size, their speed and somewhat the angle of emission ;
  2. I can hook up a particle emitter to a view. It will use the view X&Y coordinates to emit the particles but the problem with a XML-based circle drawable like here is that it's contained inside a square-based view (with a height and a width) and for strange reason, my circle is draw above that said squared-based view.

I hope I can find another library but if the current one is working, why not ? Just trying my luck out there ^^

Thanks for the help !

like image 646
Mackovich Avatar asked Dec 03 '15 10:12

Mackovich


1 Answers

The library author of Leonids made a suggestion that might help you achieve the desired effect :

(source)

plattysoft commented on Sep 19, 2016

Interesting, this is not currently supported, but you could make fork and tweak the library to add an initializer that takes a radius and spawns particles around that with a random angle.

The second part it to get attracted by the center. That should be a modifier or maybe an initializer where the acceleration depends on the angle.

Tricky, and not supported directly, but doable.

like image 135
Tommie C. Avatar answered Sep 27 '22 18:09

Tommie C.