easy config.lua questions

Hi all
I was wondering a few things about the config.lua file and hopefully some kind soul here will rush to my aid :slight_smile:

1: Default orientation - I’d like the app to default to landscape mode (with the home button to the right), and only be usable in either left or right landscape mode (if that makes sense).

2: Dynamic image resolution - I’d like the app to automatically use higher res images on the iPhone 4. Now I know this is done using the @2x suffix, but how do you set it up to do it.

3: Are there any general tutorials on the config.lua settings? The api reference seems to cover everything but I just can’t get my head around it for some reason.

Many thanks [import]uid: 7841 topic_id: 10663 reply_id: 310663[/import]

Here are the settings for such cases…

  1. You will need a build.settings file to default the screen orientation… something like this should do the trick:
settings =   
{  
 orientation =   
 {  
 default = "landscape",  
 supported =   
 {  
 "landscape",  
 },  
  
 },  
  
 iphone =  
 {  
 plist =  
 {  
 UIPrerenderedIcon = true,  
 UIApplicationExitsOnSuspend = true,  
 CFBundleIconFile = "Icon.png",  
 CFBundleIconFiles = {  
 "Icon.png",   
 "Icon@2x.png",   
 "Icon-72.png",   
 },  
 },  
 }  
  
}  

As for #2 and #3 above, take a look at this Link
Hopefully that help, Croisened
[import]uid: 48203 topic_id: 10663 reply_id: 38758[/import]

you can also see the example of DynamicImageResolution in hardware in samplecode [import]uid: 12482 topic_id: 10663 reply_id: 38759[/import]

OK, I was so hopeful I read something that would fix my dilemma of hardware resolution shenanigans. I read this:

If your application does support running on devices with different screen dimensions, the width and height MUST be the value of the target device in portrait orientation. These values are not dependent on the orientation mode of your application. If your app runs in landscape mode, you still set these values to the portrait width and height. Use the “orientation” setting in the build.settings file to define the orientation modes supported by the application.

SO I QUICKLY went and rotated and resized my screen BG graphics accordingly, since I had landscape set in my build.settings, and the Backgrounds appeared oriented incorrectly.

CORRECTION: It’s very important to make sure you’re editing the correct App’s files, and not another App’s. Because results will not be as expected when you’re not actually referring to the edited file. HOWEVER, the paragraph I mentioned above is incorrect - my graphics are saved “Landscape” orientation because they do NOT display correctly if saved as “Portrait” even when my build.settings specifies the orientation. That is bad advice above. (Copied from: Dynamic_Content_Scaling)

BUT, I’m still not satisfied because I can’t change the config.lua dynamically depending on the device (i.e. iPhone vs. iPhone4) - so Dynamic Scaling has to be the correct solution. But I have not been able to make the BG fill the screen correctly as of yet.

[import]uid: 74844 topic_id: 10663 reply_id: 49146[/import]

what is your setting in config file ??? [import]uid: 12482 topic_id: 10663 reply_id: 49154[/import]

ok by setting you are telling your app that you are working with points not pixels and in every device you are expecting width of 320 points and height of 480 points so now if you put any image at some pos

say image1.x = 160 then it will be at center of each and every device in iphone its at 160 px in iphone4 its at 320px and and in ipad its at 384 px

you can even try some different scales from here

http://developer.anscamobile.com/content/configuring-projects

if you don’t want space to be left try zoomStretch instead of letterBox

also look at ghost vs monster sample code from code exchange that will also give you good idea about scaling
:slight_smile: [import]uid: 12482 topic_id: 10663 reply_id: 49157[/import]

Currently, since my target device is iPhone it is:

application =  
{  
 content =  
 {  
 width = 320,  
 height = 480,  
 scale = "letterbox",  
 fps = 60  
 },  
}  

Now that said, I read:
Also note that the recommended 380 x 570 background size assumes a basic content size of specifically 320 x 480, and is dependent on the range of screen shapes we are trying to target. The bleed zone is outside the 320 x 480 to 380 x 570. I played with this and did not have the results I expected. The config.lua should still remain what you see above in my code slice, according to the documentation. [import]uid: 74844 topic_id: 10663 reply_id: 49156[/import]

>>ok by setting you are telling your app that you are working with points not pixels

I guess I don’t understand what config.lua would state if I wanted to work with pixels then and not points? I didn’t realize there was a difference…?

I will have to study your link more closely, I’m still trying to get my head wrapped around that. Conceptually I understand what this is doing, but in application my results are not what I’d expect. So I’m just missing something…

Your link says:
The value of “content” should be a table containing the following key-value pairs:

width (number) - the width, in pixels, of the original target device (in portrait orientation)

height (number) - the height, in pixels, of the original target device (in portrait orientation)
So I’m going to look at SampleCode/Graphics/Fishies and perhaps this is demonstrated… [import]uid: 74844 topic_id: 10663 reply_id: 49158[/import]

if you want to work with pixels then just delete this lines

width = 320,
height = 480,
scale = “letterbox”,
main difference between point and pixel is in iphone 1 point = i pixel and in iphone4 1 point = 2x2 pixel there are lots of articles on this just google it you will find lots of docs with this and it is the good way to handle different resolution

:slight_smile: [import]uid: 12482 topic_id: 10663 reply_id: 49160[/import]

One last thing, I notice that the SIM treats “iPhone4” device differently than the actual Device itself. I own an iPhone4 and I am experiencing different results on my actual Device when compared to the Simulator.

I think I saw in this thread (or another) that someone mentioned they check for screenWidth == 640 to determine if they’re actually on an iPhone4. If this is really the case, Ansca needs to correct this ASAP in my opinion. [import]uid: 74844 topic_id: 10663 reply_id: 49162[/import]

to be honest i had also read in forums about getting different position on actual device but i had not found any thing like this .

[import]uid: 12482 topic_id: 10663 reply_id: 49164[/import]