Hello,
I am working on one project that is only for IOS.
I am using below config.lua :
local targetDevice = ( system.getInfo( “model” ) )
local isTall = ( “iPhone” == system.getInfo( “model” ) ) and ( display.pixelHeight > 960 )
if isTall == false and targetDevice == “iPhone” then
application =
{
content =
{
width = 320,
height = 480,
scale = “letterbox”,
fps = 60,
--antialias = true,
xalign = “center”,
yalign = “center”,
imageSuffix =
{
["@2x"] = 2,
},
},
}
elseif isTall == true then
application =
{
content =
{
width = 320,
height = 568,
scale = “letterbox”,
fps = 60,
antialias = true,
xalign = “center”,
yalign = “center”,
},
}
elseif targetDevice == “iPad” then
application =
{
content =
{
width = 768,
height = 1024,
scale = “letterbox”,
fps = 60,
--antialias = true,
xalign = “center”,
yalign = “center”,
imageSuffix =
{
["@2x"] = 2,
},
},
}
end
I want to know that what is the best way to set image size for both orientation.
My app is in both orientation and i am recreating all the objects on device orientation change(Runtime listener for orientation)
for eg.
if i use fix pixel like:
local myImg = newImageRect(“myImg.png”,100,100)
Then this is not proper for ipad ratina and high resolution devices.
My code is like below:
_W = display.contentWidth
_H = display.contentHeight
local function createMyImage()
local imgSize = _W/2
local myImg = newImageRect(“myImg.png”,imgSize,imgSize)
myImg.x = _W/2
myImg.y = _H/2
end
createMyImage()
local function onOrientationChange(event)
DeviceOrientation = event.type
_W = display.contentWidth
_H = display.contentHeight
createMyImage()
end
Runtime:addEventListener( “orientation”, onOrientationChange )
I know that this is not a proper way to set image.
Please help me for this problem.
Thanks in advance.