I want to implement something similar like what periscope does to their live streaming app. To be specific, the countless floating heart emitted when user touch the screen. Is this could easily be achieved by SpriteKit or Cocos2D? Can anyone shed me some lights or , at least, a good starting point.
THANKS
This can be achieved through SKEmitterNode
import SpriteKit
let heartsFile = "heart-bubbles.sks"//particle file
class HeartBubblesScene : SKScene {
var emitter: SKEmitterNode?
func beginBubbling() {
emitter = SKEmitterNode(fileNamed: heartsFile)
let x = floor(size.width / 2.0)
let y = heartHeight
emitter!.position = CGPointMake(x, y)
emitter!.name = "heart-bubbles"
emitter!.targetNode = self
emitter?.numParticlesToEmit = 1
addChild(emitter!)
emitter?.resetSimulation()
}
}
class ViewController: UIViewController {
@IBOutlet weak var heartBubblesView: SKView!//Create a custom view inside view controller and set the class to SKView
let heartBubblesScene = HeartBubblesScene()
override func viewDidLoad() {
super.viewDidLoad()
heartBubblesView.presentScene(heartBubblesScene)
}
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
heartBubblesScene.beginBubbling()
}
}
Here is an example HeartAnimation
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With