Going from tvOS to iOS is easy!
It only takes a few minutes (seriously) to go from tvOS to iOS or vice versa, without making any changes to your game’s art or scene files. Here’s the long reason why….
The kit is intended to run 1920 by 1080 sized Scene files for BOTH tvOS and Universal iOS apps, with 1x images. You experienced developers are probably wondering how’s that possible… The screen size for TV is 1920 by 1080 which conveniently is the “3x” resolution of the iPhone 6 Plus, also at 1920 by 1080. So your scene files and graphics all resize down perfectly for the iPhone devices, which regardless of resolution are all that same screen ratio.
So what about that awkward iPad size? It’s simple actually. The scene resizes into the iPad without any squashing or stretching, but you see more of the scene on the top and bottom of the screen. So when designing your levels, just include a bit more of the background or ground plane below and above the height. Code wise, the kit moves the camera up some, so GUI elements still appear on top, then scans the contents of the camera for any GUI elements that are lower than 0. If found, it pushes those toward the bottom.
Note: the Home menu for the iPad clips a little off the left and the right of the screen, instead of top and bottom like the gameplay scenes.
So where to start iOS or tvOS?
When working on our demo app which is for both tvOS and iOS, we started with the TV because it’s simply way more exciting of a format for platform games. It’s incredibly fun using the Nimbus controller and trying to survive levels you’ve just created on a big screen TV.
Unfortunately if you don’t have a new Apple TV, the Simulator is no replacement. Especially not for games. Its slower first off. And second, the kit is programmed to work with Apple TV remote as a micro gamepad controller, which treats it more like a sideways oriented game controller instead of a traditional remote. So you’ll notice if you try to do basic things in the Simulator its nearly impossible. The kit uses finer controller than simple swipes on the remote’s touch pad.
So if you don’t have a new Apple TV, you’ll find it frustrating to try to develop a game without one, in which case, begin with the iOS project. Just keep in mind, we recommend keeping the scene files at 1920 by 1080. So you can copy them over to the tvOS project and not make any changes. And because you’re using a much larger size, you can work with 1x graphics, which is much easier (yes they scale down and keep their crispness).
Keep in mind, the Nimbus and other game controllers work with the kit on iOS devices. So if you want to get a feel for the TV environment without one, just buy a game controller and use it with either the iPad or iPhone. It plays identical to how it would for the TV.
What to copy?
If you’ve finished with a version of your game for tvOS or iOS and are ready to create a project for the OS you didn’t start with, its mostly just a matter of copying assets. First though, make a duplicate of the included kit files for the new project you want to copy to. This way, worst case, you can just delete and start again.
Files you’ll want to import to the new project are…
- Any Scene (.sks) files. You can overwrite existing ones like Home.sks in the finder, instead of reimporting them.
- The Game.xcassets catalog. Yes the entire catalog can be imported from one project to another, but keep in mind, the iOS kit, has three files you will probably want to keep: PauseButton, Ball, Base, and Button, which are used for the virtual joystick and virtual button.
- Any .atlas folders
- Any sounds
- Any fonts – don’t forget that the Info.plist file needs to be aware of any custom fonts, in the Fonts Provided by Application property.
What not to copy?
Don’t copy the class files, unless you’ve written some custom code yourself. There isn’t much iOS specific code, but there is a little. Most of which is in the GameScene_Touches.swift file which only exists in the iOS version.
Also you probably don’t want to copy the Assets.xcassets catalog. In the tvOS version, this includes the fancy multi-layered icons, which aren’t needed in the iOS version and the tvOS version has no need for the standard icons.
Add the Virtual Buttons and Joystick to your iOS Scene Files
Last little thing: copy and paste the PauseButton, Base, Ball and two Buttons from the demo Level1.sks scene (in the iOS version of the kit) into your own .sks files.
Most likely, you’ll want to parent them to TheCamera (so they move with the rest of the GUI if the camera follows the player). When you copy and paste sprites between scene files they lose their parent, so this is the only thing that takes a little bit of time. But you can parent multiple sprites at once, so don’t deselect them after copying.