---
title: "#8: Mixing SpriteKit into UIKit 💕"
url: https://littlebitesofcocoa.com/8-mixing-spritekit-into-uikit
author: Jake Marsh
date: 2015-05-27
published: 2015-05-27
topics: ["UIKit","SpriteKit"]
description: "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..."
---

# #8: Mixing SpriteKit into UIKit 💕

By Jake Marsh, May 27, 2015. HTML: https://littlebitesofcocoa.com/8-mixing-spritekit-into-uikit

<img src="https://media.littlebitesofcocoa.com/bite-assets/008-mixing-spritekit-into-uikit-standalone.gif" style="max-width: 224px; float: right; margin-left: 20px; margin-bottom: 20px;" />

**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 <span style='color: red'>**i'm interested**</span> button, we trigger an `SKEmitterNode`.

[Download sample project](http://j.mp/bite008)
