iosuianimationcaanimationcaemitterlayercaemittercell

How to do animation just like Periscope hearts popping up?


I need to do same animation as done in Periscope App, while user is sending heart. Hearts are popping per touch and travel randomly and disappears and eventually fade out. Each touch will generate exactly one particle (heart, in this case). The faster user touches, the more heart appears.

Just like this :

enter image description here

I have tried CAEmitterLayer, but the emitter will emit particle with a birthrate, there's no way to granularly control the emission of particle.

I don't know what I can use else to do so? I am stuck at this point.


Solution

  • There is no way to make a CAEmitterLayer do what you want, as far as I know.

    But, the way I see it, you have two options: you could create an emitter each time the user taps on the screen which would emit just one particle with random acceleration and direction (it is not very efficient, but it is fast to code), or do everything yourself: create one sprite each time the user taps on the screen, store its position, direction, speed and rotation in a matrix, modify them in the update() method and then redraw each sprite.

    I hope at least I was able to give you an idea to continue your work.