Test Questions

I’ve been working on a game for a while, and now I’m to the point where it’s working pretty well. However, I’ve never tested it out on a device. I’ve never even loaded a project I made on a device. So I have a few questions regarding device/simulator.

  1. I’ve made my game for the iPad, but I was wondering if Corona’s dynamic content scaling will work for me? I mean I have 1024x768 as the width x height, will that work on an iPhone, for example?

  2. Very broad question: How do I get from folder with Lua files, sound, and art --> App on device?

  3. When I test the app out on the device, are there any restrictions regarding Apple?

  4. What about Xcode simulator? What’s that about? I have the Xcode app, but what about the simulator that everyone keeps talking about?

Thanks in advance!

Caleb [import]uid: 147322 topic_id: 34459 reply_id: 334459[/import]

Very good questions Caleb, let me try to address each one. I’m sure we have all of this in a guide somewhere, but it won’t hurt to restate it.

1. I’ve made my game for the iPad, but I was wondering if Corona’s dynamic content scaling will work for me? I mean I have 1024x768 as the width x height, will that work on an iPhone, for example?
A lot depends on what you have in your config.lua file. Assuming you’ve set it to be 1024 x 768 and you are using letterbox scaling what will happen is that on the iPhone 4 and 4s, Corona will scale your graphics down to fit into a 640x854 box, centered in the screen. There will be 106 total pixels end up in black letterbox bars (53 each side)… assuming your backgrounds are 1024x768. You can make your backgrounds bigger, (1152x768 to be precise) and the background will fill the screen, but your 0,0 location will not be the top left corner, and your display.contentWidth, display.contentHeight will not be your bottom right either. I"m going to assume landscape out of general principle. 0,0 will be 53 pixels away from the left edge, and the other corner will have 53 pixels on the other side of far bottom, left point.

This isn’t the end of the world, because if you position something at 1120, 760 it will be on screen just beyond the 1024 point. Corona with regards to display.contentWidth thinks its off screen. Likewise on the other side to position something near the edge you would have to give it a negative X value.

The iPhone 5 adds even more space to the left of 0,0 and to the right of display.contentWidth, display.contentHeight. Your background would need to be 1363x768 to fill the iPhone 5 screen.

For the iPhone 3Gs (the oldest supported model), Corona will scale the images down accordingly, however be aware that if you expand your background to cover the letterboxed areas, that background is going to be a 2048x2048 texture and will take up 16MB of memory and the 3Gs only has 256MB and you don’t get all of that. Also the 3Gs’s processor is going to be busy downsizing all those graphics, so your performance on that device may be limited.

2. Very broad question: How do I get from folder with Lua files, sound, and art --> App on device?
The first step is to have Corona build your app. File->Build->iOS or CMD-B will bring up the build dialog. Prior to this you have many steps you have to do on the Apple Developer Provisioning Portal. You need a Key/Certificate pair for development and a pair for distribution. You need to add your test devices using the UDID for each device. Then you need to create an AppID which will give you a bundle identifier like “com.yourname.yourapp” that has to be unique. There’s a random 10 digit/letter code that is also added, but you generally don’t need to worry too much about that.

Next you create a Provisioning Profile that marries the certificate, devices, and appID into a block of code that Apple’s XCode uses to sign your application. To keep things simple, its best to use the Distirubtion AdHoc profile to build and test with. This is way too much to go into here. I recommend reading:

http://developer.coronalabs.com/forum/2012/01/10/ios-walkthrough-creating-your-certificates

and

http://developer.coronalabs.com/content/building-devices-iphoneipad

Once you have your provisioning profile, downloaded and installed in the right place, restart Corona SDK if its running or cold start it. Now you will use the Build command to build your app, selecting the provisioning profile you just created. This will produce two files in the location you said to output the build to. One will simply be your app build, the other will be a zipp’ed version. The app build is really a folder with a hidden extension of .app. The zip version bundles it up to a single file. When Corona finishes, it gives you the option to upload to the app store. You DO NOT want to do this yet. When you have your final build and you’re using the Distribution profile, you will then use this to upload to iTunes. But for testing, skip it.

Now at this point, you don’t need the zip file, it’s what gets uploaded to iTunes. At this point you have several options to get the file onto your device.

  1. Use Xcode’s Organizer. This is the simplest. Plug your phone in, launch XCode, if you have not done so, click the “Use this device for development” button. Your device will show up in the left side bar and this button is on one of the screens. Click on Applications and there is an Add button at the bottom. If everything is good, you can install the app bundle directly.

  2. Use iTunes to install it. This requires you making a special kind of file called an IPA file. Search Google to learn out. Its really easy, but this post is getting rather long and I still have more questions to answer. You drag the IPA file into the Apps area in itunes, then sync your device. I find this slower, but its the best way to give it to testers to try (You have to have their devices installed in your provisioning portal and have rebuild the provisioning profile before they can run the app)

  3. Use TestFlightApp.com. This is good if your going to have a test team, but you upload your IPA file to them and they email you with a link to install it over the air.

Once its on device, play away. And as another plug for using Xcode’s Organizer for testing, is you can monitor the device’s console.log looking for errors. Truely the best way to test your app.

3. When I test the app out on the device, are there any restrictions regarding Apple?
That is another pretty broad question. Generally, I would say no. But if you’re using Game Center, In App Purchases and such, there are special test procedures that you have to go through to test them in the sandbox and not in the live environment.

4. What about Xcode simulator? What’s that about? I have the Xcode app, but what about the simulator that everyone keeps talking about?
Just like Corona gives us a simulator to test on, if you were to write an app directly in Objective C with XCode, Apple provides a simulator to test on. Corona can use that simulator to test your app bulds on by picking Simulator on the build screen. I don’t find it very useful, but others do since Corona will launch the Xcode simulator for you. The Simulator outputs its debugging information to the Mac’s “console” app which I find hidden and harder to work with, but that’s just me. But it can be faster than installing on the app if you’re testing things like Facebook or ads that don’t run in the simulator.

Hope this answers your questions.
[import]uid: 199310 topic_id: 34459 reply_id: 137011[/import]

WOW!!!

That was amazing! That just answered every single inkling of a hidden thought of a question! That must have taken a long time to write… Thank you so much!

If I have any other questions, I’ll just post - although I think you’ve answered all of my questions about this for a good while :slight_smile:

I’ll have to get busy testing… [import]uid: 147322 topic_id: 34459 reply_id: 137016[/import]

Very good questions Caleb, let me try to address each one. I’m sure we have all of this in a guide somewhere, but it won’t hurt to restate it.

1. I’ve made my game for the iPad, but I was wondering if Corona’s dynamic content scaling will work for me? I mean I have 1024x768 as the width x height, will that work on an iPhone, for example?
A lot depends on what you have in your config.lua file. Assuming you’ve set it to be 1024 x 768 and you are using letterbox scaling what will happen is that on the iPhone 4 and 4s, Corona will scale your graphics down to fit into a 640x854 box, centered in the screen. There will be 106 total pixels end up in black letterbox bars (53 each side)… assuming your backgrounds are 1024x768. You can make your backgrounds bigger, (1152x768 to be precise) and the background will fill the screen, but your 0,0 location will not be the top left corner, and your display.contentWidth, display.contentHeight will not be your bottom right either. I"m going to assume landscape out of general principle. 0,0 will be 53 pixels away from the left edge, and the other corner will have 53 pixels on the other side of far bottom, left point.

This isn’t the end of the world, because if you position something at 1120, 760 it will be on screen just beyond the 1024 point. Corona with regards to display.contentWidth thinks its off screen. Likewise on the other side to position something near the edge you would have to give it a negative X value.

The iPhone 5 adds even more space to the left of 0,0 and to the right of display.contentWidth, display.contentHeight. Your background would need to be 1363x768 to fill the iPhone 5 screen.

For the iPhone 3Gs (the oldest supported model), Corona will scale the images down accordingly, however be aware that if you expand your background to cover the letterboxed areas, that background is going to be a 2048x2048 texture and will take up 16MB of memory and the 3Gs only has 256MB and you don’t get all of that. Also the 3Gs’s processor is going to be busy downsizing all those graphics, so your performance on that device may be limited.

2. Very broad question: How do I get from folder with Lua files, sound, and art --> App on device?
The first step is to have Corona build your app. File->Build->iOS or CMD-B will bring up the build dialog. Prior to this you have many steps you have to do on the Apple Developer Provisioning Portal. You need a Key/Certificate pair for development and a pair for distribution. You need to add your test devices using the UDID for each device. Then you need to create an AppID which will give you a bundle identifier like “com.yourname.yourapp” that has to be unique. There’s a random 10 digit/letter code that is also added, but you generally don’t need to worry too much about that.

Next you create a Provisioning Profile that marries the certificate, devices, and appID into a block of code that Apple’s XCode uses to sign your application. To keep things simple, its best to use the Distirubtion AdHoc profile to build and test with. This is way too much to go into here. I recommend reading:

http://developer.coronalabs.com/forum/2012/01/10/ios-walkthrough-creating-your-certificates

and

http://developer.coronalabs.com/content/building-devices-iphoneipad

Once you have your provisioning profile, downloaded and installed in the right place, restart Corona SDK if its running or cold start it. Now you will use the Build command to build your app, selecting the provisioning profile you just created. This will produce two files in the location you said to output the build to. One will simply be your app build, the other will be a zipp’ed version. The app build is really a folder with a hidden extension of .app. The zip version bundles it up to a single file. When Corona finishes, it gives you the option to upload to the app store. You DO NOT want to do this yet. When you have your final build and you’re using the Distribution profile, you will then use this to upload to iTunes. But for testing, skip it.

Now at this point, you don’t need the zip file, it’s what gets uploaded to iTunes. At this point you have several options to get the file onto your device.

  1. Use Xcode’s Organizer. This is the simplest. Plug your phone in, launch XCode, if you have not done so, click the “Use this device for development” button. Your device will show up in the left side bar and this button is on one of the screens. Click on Applications and there is an Add button at the bottom. If everything is good, you can install the app bundle directly.

  2. Use iTunes to install it. This requires you making a special kind of file called an IPA file. Search Google to learn out. Its really easy, but this post is getting rather long and I still have more questions to answer. You drag the IPA file into the Apps area in itunes, then sync your device. I find this slower, but its the best way to give it to testers to try (You have to have their devices installed in your provisioning portal and have rebuild the provisioning profile before they can run the app)

  3. Use TestFlightApp.com. This is good if your going to have a test team, but you upload your IPA file to them and they email you with a link to install it over the air.

Once its on device, play away. And as another plug for using Xcode’s Organizer for testing, is you can monitor the device’s console.log looking for errors. Truely the best way to test your app.

3. When I test the app out on the device, are there any restrictions regarding Apple?
That is another pretty broad question. Generally, I would say no. But if you’re using Game Center, In App Purchases and such, there are special test procedures that you have to go through to test them in the sandbox and not in the live environment.

4. What about Xcode simulator? What’s that about? I have the Xcode app, but what about the simulator that everyone keeps talking about?
Just like Corona gives us a simulator to test on, if you were to write an app directly in Objective C with XCode, Apple provides a simulator to test on. Corona can use that simulator to test your app bulds on by picking Simulator on the build screen. I don’t find it very useful, but others do since Corona will launch the Xcode simulator for you. The Simulator outputs its debugging information to the Mac’s “console” app which I find hidden and harder to work with, but that’s just me. But it can be faster than installing on the app if you’re testing things like Facebook or ads that don’t run in the simulator.

Hope this answers your questions.
[import]uid: 199310 topic_id: 34459 reply_id: 137011[/import]

WOW!!!

That was amazing! That just answered every single inkling of a hidden thought of a question! That must have taken a long time to write… Thank you so much!

If I have any other questions, I’ll just post - although I think you’ve answered all of my questions about this for a good while :slight_smile:

I’ll have to get busy testing… [import]uid: 147322 topic_id: 34459 reply_id: 137016[/import]

Hi - I’ve done the same thing: I built an app with the config improperly set at 1024 x 768 for iPad and built all the graphics to work perfectly with that. I’ve now realized there are other platforms I’d like to accommodate, at the very least iPad Retina, but also iPhones etc. So I’ve spent hours reading, digesting and trying to understand everything I can find on proper config file including the Ultimate config.lua., and dynamic scaling.

When I set up the config now with lower resolutions, nothing is functioning correctly at all. All of the graphics are much too large even on iPad in simulator and all distorted. I’ve tried changing those graphics file names and adding the @2x to them (because essentially they are the correct 2x graphics for iPad) and all that does is cause an error that the simulator can no longer find the graphics files referenced in the code. I thought as soon as I added the correct config and the @2x & @4x parts of that config, it would automatically choose the graphics with the @2x appended to them if I’m using the iPad in simulator.

Any idea what is happening here?

I think that the BIGGEST thing to impress upon new developers is properly setting up the config with the correct numbers FIRST and then building graphics and elements based on the platform(s) you’re targeting. Seems like doing it the way I’ve done causes complete havoc and is making me think I need to start all over again as nothing is functioning after changing the config.

Original config was:

application =

   {

      content =

      {

         width = 1024,

         height = 768,

         scale = “letterBox”,

         xAlign = “center”,

         yAlign = “center”,

         fps = 30,

         audioPlayFrequency = 22050,

      },

   }

And I changed it based on the ultimate config tutorial and discussion to:

if ( string.sub( system.getInfo(“model”), 1, 4 ) == “iPad” ) then

   application =

   {

      content =

      {

         width = 320,

         height = 480,

         scale = “letterBox”,

         xAlign = “center”,

         yAlign = “center”,

         fps = 30,

         audioPlayFrequency = 22050,

         imageSuffix =

         {

            ["@2x"] = 1.5,

            ["@4x"] = 3.0,

         },

      },

   }

else 

    – all other devices

    local h = math.round(320 * (display.pixelHeight / display.pixelWidth));

    application = {

        content = {

            width = 320,

            height = h,

            scale = “letterBox”,

             xAlign = “center”,

             yAlign = “center”,

            fps = 30,

            audioPlayFrequency = 22050,

            imageSuffix = {

                ["@2x"] = 1.5,

                ["@4x"] = 3.0,

            },

        },

    }

end

Hi Tim,
I optimistically believe we can “save” your original config. :slight_smile:

It’s not “wrong” to start with iPad 1&2 dimensions. You just need to work in reverse somewhat for iPhone 4/5 and other smaller devices… and of course, work up for iPad Retina and other HD tablets.

I’m not on my computer now (on the IPad), but can you give me your original config setup and a quick list of other devices you want to target? I can then later give some further advice on how to accomplish it.

Regards,
Brent Sorrentino

Hi Brent,

thanks for the reply. The short answer to your question is in my original post above ^^. The config I originally used is first and the config I want to use is second. I need my graphics created to work with the 1st config to work with the 2nd config.

Thanks,

Tim

Hi - I’ve done the same thing: I built an app with the config improperly set at 1024 x 768 for iPad and built all the graphics to work perfectly with that. I’ve now realized there are other platforms I’d like to accommodate, at the very least iPad Retina, but also iPhones etc. So I’ve spent hours reading, digesting and trying to understand everything I can find on proper config file including the Ultimate config.lua., and dynamic scaling.

When I set up the config now with lower resolutions, nothing is functioning correctly at all. All of the graphics are much too large even on iPad in simulator and all distorted. I’ve tried changing those graphics file names and adding the @2x to them (because essentially they are the correct 2x graphics for iPad) and all that does is cause an error that the simulator can no longer find the graphics files referenced in the code. I thought as soon as I added the correct config and the @2x & @4x parts of that config, it would automatically choose the graphics with the @2x appended to them if I’m using the iPad in simulator.

Any idea what is happening here?

I think that the BIGGEST thing to impress upon new developers is properly setting up the config with the correct numbers FIRST and then building graphics and elements based on the platform(s) you’re targeting. Seems like doing it the way I’ve done causes complete havoc and is making me think I need to start all over again as nothing is functioning after changing the config.

Original config was:

application =

   {

      content =

      {

         width = 1024,

         height = 768,

         scale = “letterBox”,

         xAlign = “center”,

         yAlign = “center”,

         fps = 30,

         audioPlayFrequency = 22050,

      },

   }

And I changed it based on the ultimate config tutorial and discussion to:

if ( string.sub( system.getInfo(“model”), 1, 4 ) == “iPad” ) then

   application =

   {

      content =

      {

         width = 320,

         height = 480,

         scale = “letterBox”,

         xAlign = “center”,

         yAlign = “center”,

         fps = 30,

         audioPlayFrequency = 22050,

         imageSuffix =

         {

            ["@2x"] = 1.5,

            ["@4x"] = 3.0,

         },

      },

   }

else 

    – all other devices

    local h = math.round(320 * (display.pixelHeight / display.pixelWidth));

    application = {

        content = {

            width = 320,

            height = h,

            scale = “letterBox”,

             xAlign = “center”,

             yAlign = “center”,

            fps = 30,

            audioPlayFrequency = 22050,

            imageSuffix = {

                ["@2x"] = 1.5,

                ["@4x"] = 3.0,

            },

        },

    }

end

Hi Tim,
I optimistically believe we can “save” your original config. :slight_smile:

It’s not “wrong” to start with iPad 1&2 dimensions. You just need to work in reverse somewhat for iPhone 4/5 and other smaller devices… and of course, work up for iPad Retina and other HD tablets.

I’m not on my computer now (on the IPad), but can you give me your original config setup and a quick list of other devices you want to target? I can then later give some further advice on how to accomplish it.

Regards,
Brent Sorrentino

Hi Brent,

thanks for the reply. The short answer to your question is in my original post above ^^. The config I originally used is first and the config I want to use is second. I need my graphics created to work with the 1st config to work with the 2nd config.

Thanks,

Tim

Hi Tim,

Sorry for the delayed response on this. If you want to use your iPad graphics in a more “flexible” config setup (i.e. one that works for iPhone too), perhaps this will work:

[lua]

application = 

{

    content = 

    { 

        fps = 30,

        width = 768,

        height = 1024,

        scale = “letterbox”,

        xAlign = “center”,

        yAlign = “center”,

        

        imageSuffix =

        {

            [""] = 0.4,       --iPhone3/3GS

            ["@2x"] = 0.8,    --iPhone4 / iPhone5 / iPod-Touch 4th-gen / iPod-Touch 5th-gen

                              --iPad1 / iPad2

            ["@4x"] = 2.0     --Retina iPad

        }

    }

}

[/lua]

So in this case, according to the suffix setup, you’ll use the “@2x” images for iPhone 4/5, iPod Touch 4/5, and iPad 1 & 2. Then, for Retina iPad, you’ll use “@4x” images. And if you still care about iPhone 3/3GS, you can use images with no suffix appended at all.

Hope this helps,

Brent

Hi Tim,

Sorry for the delayed response on this. If you want to use your iPad graphics in a more “flexible” config setup (i.e. one that works for iPhone too), perhaps this will work:

[lua]

application = 

{

    content = 

    { 

        fps = 30,

        width = 768,

        height = 1024,

        scale = “letterbox”,

        xAlign = “center”,

        yAlign = “center”,

        

        imageSuffix =

        {

            [""] = 0.4,       --iPhone3/3GS

            ["@2x"] = 0.8,    --iPhone4 / iPhone5 / iPod-Touch 4th-gen / iPod-Touch 5th-gen

                              --iPad1 / iPad2

            ["@4x"] = 2.0     --Retina iPad

        }

    }

}

[/lua]

So in this case, according to the suffix setup, you’ll use the “@2x” images for iPhone 4/5, iPod Touch 4/5, and iPad 1 & 2. Then, for Retina iPad, you’ll use “@4x” images. And if you still care about iPhone 3/3GS, you can use images with no suffix appended at all.

Hope this helps,

Brent