---
title: "SpriteKit bites - Little Bites of Cocoa"
description: "Little Bites of Cocoa about SpriteKit: short tips and techniques for iOS and Mac development, each a brief explanation of one concept, technique or tool."
url: "https://littlebitesofcocoa.com/topics/14-spritekit"
author: "Jake Marsh"
---
# Bites about: [SpriteKit](https://littlebitesofcocoa.com/topics/14-spritekit)

Topics

- [UIKit](https://littlebitesofcocoa.com/topics/1-uikit)
- [SpriteKit](https://littlebitesofcocoa.com/topics/14-spritekit)

## [#8: Mixing SpriteKit into UIKit 💕](https://littlebitesofcocoa.com/8-mixing-spritekit-into-uikit)

 Wednesday May 27th, 2015

Topics

- [UIKit](https://littlebitesofcocoa.com/topics/1-uikit)
- [SpriteKit](https://littlebitesofcocoa.com/topics/14-spritekit)

![Image from bite #8: Mixing SpriteKit into UIKit](https://media.littlebitesofcocoa.com/bite-assets/008-mixing-spritekit-into-uikit-standalone.gif)

**SpriteKit** is a phenomenal 2D game engine that ships in iOS and OS X. It has brought on a sort of renaissance amongst both amateur and professional game developers.

But what about using SpriteKit for fun, (and profit 🎉), and for things other than making games? What if we used SpriteKit to add special effects and final touches to our user interfaces?

```swift
class HeartBubblesScene : SKScene {
  var emitter: SKEmitterNode?

  override func didMoveToView(view: SKView) {
    // make scene's size == view's size
    scaleMode = .ResizeFill
    backgroundColor = UIColor.whiteColor()
  }

  func beginBubbling() {
    if let e = emitter {
      e.resetSimulation()
    } else {
      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

      addChild(emitter!)
    }
  }
}
```

```swift
class PotentialMatchViewController: UIViewController {
  @IBOutlet weak var heartBubblesView: SKView!
  let heartBubblesScene = HeartBubblesScene()

  override func viewDidLoad() {
    super.viewDidLoad()

    heartBubblesView.presentScene(heartBubblesScene)
  }

  @IBAction func interestedTapped(sender: UIButton) {
    heartBubblesScene.beginBubbling()
  }
}
```

Here we're adding an awesome finishing touch to this pretend dating app. When the user taps the **i'm interested** button, we trigger an `SKEmitterNode`.

[Download sample project](http://j.mp/bite008)

 

 
