Buttons in the Pinball Games iOS and tvOS Starter Kit
(and the SelectionOrder and Columns properties)
Setting up buttons in your table scene, or starting menu scene, involves three entries in the property list. Briefly, here’s what each is for.
- Buttons – a dictionary containing sub-dictionaries each with the name of a button in your scene.
- SelectionOrder – an array listing the selection order of the buttons. This order is important for tvOS apps since the user can’t simply touch the screen to choose a button. So you need to define which button should be selected first, second, third, etc when using the Apple TV remote or an external controller. This is also used on iOS apps that have external game controllers connected.
- Columns – the number of columns your buttons are arranged in.
The Buttons dictionary lists all buttons in your scene. Each dictionary name should match a button in the scene. Buttons are nothing more than a sprite with the Name property set….
…and the Custom Class property set to Button (as seen below)….
Be sure to switch from the Attribute inspector to the Custom Class inspector.
The SelectionOrder array defines the order your buttons should be selected in if the app is run on the Apple TV or played with an external game controller on iOS. Your button names should be listed in the order they visually appear in the app, from top to bottom (if arranged in a single column), or from left to right (if arranged in multiple columns, as seen in the image below ).
The Columns property lists the number of columns your buttons are arranged in. By default this property is set to 1.
Different strokes for different folks…
Since your pinball app’s orientation will most likely different between tvOS and iOS, you might need to define your Buttons, SelectionOrder, or Columns values depending on the device.
With this in mind, you can add the following extensions to any of those property names…
So in the example above, if the app was run on the Apple TV, only the ButtonsTV, SelectionOrderTV, and ColumnsTV properties would be used.