0

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.

halfer
  • 19,824
  • 17
  • 99
  • 186
NSPratik
  • 4,714
  • 7
  • 51
  • 81
  • 1
    please vote to undelete my answer @eric-aya, david-makogon, dippas may not have noticed that it was the accepted answer. – ishandutta2007 Jul 21 '17 at 04:34
  • Yes, that answer shouldn't be deleted.. – NSPratik Jul 21 '17 at 05:24
  • 1
    The links suggested by @ishandutta2007 were [this one](https://cocoapods.org/pods/JRMFloatingAnimation) and [this one](https://github.com/saidmarouf/FloatingHearts). That answer is likely to have been deleted for being essentially "link only" - we ask that answers are expanded upon on Stack Overflow. – halfer Apr 06 '18 at 20:48

1 Answers1

2

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.

RoberRM
  • 883
  • 9
  • 18