Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
How to set Retina to work perfectly? — Gideros Forum

How to set Retina to work perfectly?

______ Member
edited July 2012 in General questions
I'm trying to make my app work with the 4 resolutions of iOS devices, without success. I've tried almost every combination of dimensions/scale mode/retina display. I'm using Box2D to set boundaries based on the width/height, but they show up at random places for each resolution, except when I set dimensions to 480 x 320, and scale mode to top left (My app runs in Landscape mode only).

Here's some code that I'm using.
require "box2d"
 
local world = b2.World.new(0, 9.8)
 
-- physics boundries
 
local width = application:getLogicalWidth()
local height = application:getLogicalHeight()
print(width, height)
local boundries = {
	top = b2.EdgeShape.new(0, 0, width, 0),
	right = b2.EdgeShape.new(width, 0, width, height),
	bottom = b2.EdgeShape.new(width, height, 0, height),
	left = b2.EdgeShape.new(0, height, 0, 0)
}
 
for side, shape in pairs(boundries) do
	local body = world:createBody({})
	body.name = side
	body:createFixture { shape = shape, density = 0 }
end
 
-- debug
local debugDraw = b2.DebugDraw.new()
world:setDebugDraw(debugDraw)
stage:addChild(debugDraw)
I want my app to automatically scale in every possible resolution. I'll be using the dimensions of my objects as a percentage of the width/height, so that wouldn't be a problem.

Any ideas?

Likes: thomas2k6

People call me "underscore".
+1 -1 (+1 / -0 )Share on Facebook

Comments

  • As far as i read somewhere inside this forum even you are working on landscape in your
    "Project properties" your logical dimensions should be set to 320x480 not 480x320 or
    480x800 not 800x480.

    Maybe it is your problem? As a said i am not sure just a wild guess:D
  • ______ Member
    edited July 2012
    Hmm. I did that, set scale mode to Pixel Perfect, and I'm still getting weird layouts. Example attached. The border is set by box2d's debug draw mode.
    Screen Shot 2012-07-24 at 8.00.05 PM.png
    1183 x 825 - 251K
    People call me "underscore".
  • There is no attachment. Look at this post it is not box 2d but some good formulas are there to set images to spesific loacations like center, top left, top right. (resolution free)
    http://www.giderosmobile.com/forum/discussion/586/automatic-screen-scaling
  • And finally if you haven't checked out yet please look to this tutorial also.
    http://www.giderosmobile.com/documentation/automatic_image_resolution.html
  • ______ Member
    Attachment didn't upload in the first attempt. I edited and added it.

    As for the links, the first one looks interesting. I'll give it a shot unless someone has a better idea / more experience on this :)
    People call me "underscore".
  • ______ Member
    Looking closely, I don't think that link is applicable to me. I'm testing this only on iPhone/iPad normal and retina versions. All of those have the same width/height ratio.
    People call me "underscore".
  • ar2rsawseenar2rsawseen Maintainer
    As far as I know Ipad and Iphone does not have same screen ratio

    try setting up something like this in the beginning of your app
    application:setOrientation(Stage.PORTRAIT)
    application:setLogicalDimensions(640, 960)
    application:setScaleMode("letterbox")
  • ______ Member
    Hmm, that seems to work for Portrait mode perfectly :)

    But when I tried LANDSCAPE_LEFT
    application:setOrientation(Stage.LANDSCAPE_LEFT)
    application:setLogicalDimensions(480, 320)
    application:setScaleMode("letterbox")
    It only fills a part of the screen even on 320x480 resolution (with orientation set to Landscape Left). Also tried setting dimensions to (320, 480) but that didn't work.

    Any ideas @ar2rsawseen?
    People call me "underscore".
  • ar2rsawseenar2rsawseen Maintainer
    edited July 2012
    Use content dimensions:
    local width = application:getContentWidth()
    local height = application:getContentHeight()
    instead of logical dimensions, because getContent takes orientation into account.

    More info: http://appcodingeasy.com/Gideros-Mobile/Difference-between-content-logical-and-device-dimensions-in-Gideros-Mobile
  • ______ Member
    Perfect @ar2rsawseen!
    People call me "underscore".
Sign In or Register to comment.