User Tools

Site Tools


Porting a game to the iPad

In the following I'm going to describe problems I stumpled upon while porting a game based on the orx engine from windows to the ipad.

XCode project

You could create your own project and link the orx library. But I would recommend just to use the XCode project that's part of the orx sources. It already contains a sample project and has all the necessary compiler settings set. If you choose to compile orx as a library and link it to a custom project make sure to create a fat library that contains binaries for both the simulator (x86 architecture) and the device (ARM architecture).

File layout

There are different ways in which you can layout your project. If you've worked on Unix systems you probably separated all binaries from the config and other data files. Maybe it looks like this:

It's now important to know that you can not do this on the iOS platform. Your executable will always reside in the root folder. So once the game is copied to the device it will look like this:
As all the paths are relative to the executable you have to change all the paths both in the config files and the sources. It's not that big a deal, you just have to be aware of that fact.

Hierarchical file structure

The hierarchical file structure can be used on the iOS platform as well. To do so just drag your data folder into your XCode project. Check that box that says “create references to folder…” or something like this. Now your data folder should appear blue inside XCode. Furthermore it will be added to the “Copy Bundles Resources” build phase.

Landscape mode

By default a game based on orx is displayed in portrait mode on the ipad. so in order to have a landscape mode do the following:

  • in your add an option called UIInterfaceOrientation and set the value to UIInterfaceOrientationLandscapeLeft

Now the application is running in landscape mode. Meaning that if you for example connect a projector the game will appear in landscape mode on that one. Note however that the game itself is still drawn in portrait mode. In order to overcome this you have to do some tricks with the camera. Basically you have one camera rotated by 90 degrees that's not being used directly and one camera that is -90 degrees rotated and used to place UI elements relatively to a camera. The latter camera will not be associated with a viewport but have the “real” camera as a parent. the config will in the end look something like this:

ScreenWidth   = 1024
ScreenHeight  = 768
Title = FancyIPadApp

Camera          = Camera
BackgroundColor = (153,153,153)

;Camera for UI positioning (meaning positioning objects relative to the camera)
ParentCamera = Camera
FrustumWidth  = 1280
FrustumHeight = 960
Rotation = -90

FrustumWidth  = 960
FrustumHeight = 1280
Rotation = 90
FrustumFar    = 1000.0
FrustumNear   = 0.0

Graphic = BGGraphic 
Position = (0, 0, 0.0001)
ParentCamera = UICamera
UseParentSpace = position
Pivot = center

en/tutorials/ipadport.txt · Last modified: 2020/08/31 07:11 (4 years ago) by sausage