SKPopMenu: Swift tile-based menu for SpriteKit 🎈

jxvaUdIF4NAGI

 

Ever need to just quickly present a few options to the user in a SpriteKit game? There are lots of menu options for UIKit-based iOS apps, but when it came time to add a simple, re-usable menu in my SpriteKit game, I couldn’t find what I needed.

Enter SKPopMenu: a fast, tile-based menu for SpriteKit written in Swift.

Github page

Download SKPopMenuExample Xcode project

 

Features

  • Supports 1-6 menu items
  • Customize each menu item with a color and a label or sprite.

 

Installation

  • Open the SKPopMenuExample Xcode project, and drag and drop SKPopMenu.swift into your Xcode project

 

Usage

In your SKScene, add the following:

 

Simulator Screen Shot Friday, July 29, 2016, 9.00.14 PM

Note: If you choose an odd number of items, the top-most item will be fullscreen width.

 

To set all sections to the same color:

To set a specific color to section 1:

To change the text label of section 3:

To add a sprite to section 5:

To change the name of section 6:

To show the menu:

To hide the menu:

Show/hide example:

Delegate methods (optional)

  • Add the protocol to your SKScene’s class definition:

  • Remember to set pop.popMenuDelegate = self

 

To get notified when a section is tapped:

 

To get notified when the menu has appeared/disappeared:

 

Github page

Download SKPopMenuExample Xcode project