displayGroup and operations on it

Hi,
I am trying to create a landscape based project. There is no native support for orientation change other than setting it in the config.lua files, is there?

Now I am trying to place all the elements on this layout. I am then trying to scale the whole group to support iPhone3 and iPhone4 resolutions.

The issue,

  1. I create a displayGroup and place a background in it of 960x640 I have to play with the referencePoint and set it for each subsequent element, the most irritating part, maybe I am missing something here, is that these do not align with the 0,0 of the group.

IMHO, any element placed on the group is relative to the group, so

 local theGroup = display.newGroup()  
 local theBackground = display.newImageRect(theGroup, "somebackground.png", 960, 640)  
  
 local theImage1 = display.newImage(theGroup, "someImage1.png")  
 theImage:setReferencePoint(display.TopLeftReferencePoint)  
 theImage.x=0  
 theImage.y=0  
  
 --Now turn the whole thing around and scale it for iPhone3  
 theGroup:setReferencePoint(display.BottomLeftReferencePoint)  
 theGroup:rotate(90)  
 theGroup.x=0  
 theGroup.y=0  
 theGroup:scale(0.5,0.5)  

This logically should work with the background image covering the whole display area and be scaled for the iPhone3

BUT, the images are all over the place

The issue is why do I have to set all this, there must be an easier way that I am missing and why do I have to use TopLeft for some and BottomLeft for some images?

shouldn’t the co-ordinate system be consistent?

cheers,

Jayant C Varma

[import]uid: 3826 topic_id: 3390 reply_id: 303390[/import]

I even tried to substitute the object.x to object.xOrigin, still nothing. Warum??

EDIT:
I set the build.settings to make the device landscape and that seems to kind of work with the referencePoint and .x, .y co-ordinates.

Why can I not create the whole interface and then just rotate the whole screen by 90 degrees?

cheers,

Jayant C Varma [import]uid: 3826 topic_id: 3390 reply_id: 10091[/import]

Hi Jayant,

I’m not sure if this is causing the issues you’re experiencing but a couple of comments about newImageRect():

  • The image you specify in newImageRect() method should be the base image for the iPhone 3G configuration (the “reference” device), and the width and height you specify should match the dimensions of that image in *portrait* mode. For example:

local theBackground = display.newImageRect(theGroup, “somebackground.png”, 320, 480)

Your project folder should also contain your hi-res bg image (“somebackground@2.png”) and a config.lua file that looks like this:

application =  
{  
 content =  
 {  
 width = 320,   
 height = 480,  
 scale = "zoomEven" -- zoom to fill screen, possibly cropping edges  
 },   
 imageSuffix =  
 {  
 ["@2"] = 2,  
 },  
}  

Corona will pick the hi-res version at runtime on iPhone 4.

If your app is landscape-only, your build.settings file could look like:

settings = {  
 orientation =  
 {  
 default = "landscapeRight",  
 supported = { "landscapeLeft", "landscapeRight"},  
 },  
}   

I realize this doesn’t answer all your questions, but I’m wondering if the group/reference point weirdness might be related to how you’re using newImageRect(). Lmk.

Tim
[import]uid: 8196 topic_id: 3390 reply_id: 10112[/import]

Hi Tim,
I added a config.lua and a build.settings file that sets the orientation to Landscape only. The reason that I was avoiding the build.settings was that on an Android, it gets ignored (at least that’s what the documents say)

I got rid of the background which is created using the newImageRect() function, the other images created using newImage() are still a bit off and do not show at 0,0 when rotated.

So I have to actually set the StartX as the width of the device and the StartY as 0, and then place the elements according to that, this still kind of goes astray.

By adding the build.settings, I do not have to rotate or play around with other settings, I just have to scale the mainGroup by half and it fits perfectly on the iPhone and non scaled perfect on the iPhone4. That way rather than have two sets of graphics, I can use the High-Res graphics and scale them down on the low-res device. Works fine on the simulator, did not get to checking it on the device as yet, but via objective-C it works perfectly fine.

cheers,

Jayant C Varma [import]uid: 3826 topic_id: 3390 reply_id: 10229[/import]