Reputation: 179
I have an image of a pause button and an image of a redo button. I want the pause button to be in the top left corner, and the redo button to be below it. If I place these images how I want them, and change device view, they are in the same relative position, but not in the very corner. All of my other background images seem to fit every device perfect. If I change the config settings, the two buttons are in the right spot, but everything else is no longer centered. The dimensions of my project are 800 x 1200 sideways orientation. Thanks!
Upvotes: 0
Views: 1238
Reputation: 3063
If you have an object:
local pauseButton = display.newImageRect("pausebtn.png", 64, 64)
pauseButton.x = 64
pausebutton.y = 64
local redoButton = display.newImageRect("redobtn.png", 64, 64)
redoButton.x = 64
redoButton.y = 128
then regardless of orientation your pauseButton will be centered on 64, 64 and your redoButton will be centered on 64, 128. Keep in mind that buy default positioning is center based. So if you have a 50 pixel by 50 pixel image and you want to have it flush to the top left corner, then you want to draw it at 25, 25.
You shouldn't need to be making changes to your config.lua.
UPDATE: It sounds like you may not be adapting your content area based on the screen shape. We wrote a blog post on how to handle this case:
http://www.coronalabs.com/blog/2012/12/04/the-ultimate-config-lua-file/
We have recently updated this with a followup that simplifies this even more:
http://www.coronalabs.com/blog/2013/09/10/modernizing-the-config-lua/
You probably should read them in order as the 2nd one assumes you understand the concepts in the first one.
Upvotes: 1