Export to XCODE - Can you set the size to be an iPhone version instead of ipad?

you’re welcome @time_trial . To be honest that bit is theory until I test it tonight and I’m sure there’s someone out there with a better and more easier way, but for now it makes sense to me so I’ll give it a go.

I’ll let you know how I get on.

thanks for all the advice!


It works!

by creating graphics and positions based on dividing the screensize into 10ths, 20ths etc… I can work the positions in photoshop design of 320x480 (iphone 4S) and then each device thats bigger, like an IPAD or an Iphone 5S will scale it accordingly.

I’m so freaken excited!

@Majormorgan - You are not doing anything with the macros, that is why they are having no effect.

The idea is that you test what device you are working on and then use the appropriate image. For example:

if (IS_IPAD) {
    // Use iPad images }
else if (IS_IPHONE_5) {
    // Use images for 4 inch screen }
   // Use 3.5 inch images }

This is if you want to make the changes from the objective C code. You wouldn’t normally do this within the AppDelegate - usually it is within the relevant view controller.

However, I suspect you really want to make the changes from within the Lua code. If so, then you can use something like:

function deviceIsIpad()

    if CurrentOrientation == LANDSCAPE_LEFT 
      or CurrentOrientation == LANDSCAPE_RIGHT then
        if WIDTH == 1024 then
            return true
            return false
        if WIDTH == 768 then
            return true
            return false

To work out what device your app is running on. You can then just use “if deviceIsIpad()” to work out which images to load.

Your scaling approach will also work but watch out for the aspect ratios (e.g. these are different for an iPhone 5 and iPhone 4 so the images will look different on the 2 devices). In general you are better using bigger images and scaling down rather than vice versa, but since you are looking for a pixelated effect this may not matter.

Hey @reefwing thanks for the heads up. The Xcode side is a kicker for me. Too complex. The good news is that the code I wrote in Lua works perfect with even one additional side effect.

So the problem I had was I had hard coded the pixel values in my first engine which meant everything was twice as big on screen on the iPhone and also just bottom left corner visible.

I had hoped that scaling the whole game worked automatically like in flash when you build an animation inside a clip, you can place the clip on the stage and scale it and everything inside scales perfectly including code. But it didn’t and people had excellent suggestions in terms of how to rebuild the engine (or rather the maths part) to work with width and height percentages.

Well in Lua that worked and also when I compiled the Xcode and ran it it worked. I did have one Xcode glitch but that was because I had a number in a sprite name and Xcode thought lua was trying to pass that number with the image. A quick rename in file and code and it worked well.

Now to the interesting side effect of my scaling technique.

So if you recall I’ve created two variables:

scalerX = WIDTH/100
scalerY = HEIGHT/100

This gives me a percentage of the screen width and height that it can use to set object x position and width with scalerX and applying a multiplier like *10 giving me 10 percent of the width to use as either a placement of x or width of objects,

It works really well and I’ve based my game design and math around an iPhone 4 at 320x480 pixels or points. I’m not playing a landscape game but I could work that out easily too using the same code and a rotation.

The advantage if working 320x480 is that it is the middle ratio of size between the iPad (wider by about 10 or 15% and also between the iPhone 5 which is about 10 or 15% taller.

So both screens stretch a little. The iPad is fatter and the iPhone 5 is taller images.

And the iPhone 4 is just right.

The side effect is all my maths is done on the scalerX and ScalerY positions and divisions.

So if my iPhone 5 is taller and I can detect the height as in your code @reefwing I could set the scalerY = height/110 instead of 100 for just iphone 5 displays to make it slightly shorter and all the maths for position scales down with it. For iPad I scale the height to be /90 which makes it a little taller. That way all graphics are set to look as square as they were intended too and I don’t have to recode all my measurements for every little thing.

As my pixel graphics are 1 pixel drawn they scale up lovely.

Make sense?

@Majormorgan - very impressive.

It all hinges on the device detection @reefwing which is where your code is very handy! But at the moment I can mannual set the scalerY whilst testing and it all looks great.

Thank you for all your help and advice @reefwing !

@Reefwing and @Majormorgan thank you guys! You are helping me to solve the device sizes.

@CodeaNoob, this can help us! :)>-

@erickyamato - pleasure