-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathViewController.swift
More file actions
67 lines (42 loc) · 1.43 KB
/
ViewController.swift
File metadata and controls
67 lines (42 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
//
// ViewController.swift
// HeartAnimation
//
// Created by Arjun Kodur on 1/28/16.
// Copyright © 2016 Arjun Kodur. All rights reserved.
//
import UIKit
import SpriteKit
let heartHeight: CGFloat = 18.0
let heartsFile = "heart-bubbles.sks"
class HeartBubblesScene : SKScene {
var emitter: SKEmitterNode?
override func didMoveToView(view: SKView) {
scaleMode = .ResizeFill // make scene's size == view's size
backgroundColor = UIColor.whiteColor()
}
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!
@IBOutlet weak var label: UILabel!
let heartBubblesScene = HeartBubblesScene()
override func viewDidLoad() {
super.viewDidLoad()
heartBubblesView.presentScene(heartBubblesScene)
}
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
heartBubblesScene.beginBubbling()
label.text = ""
}
}