Hey, all. I have been looking diligently trying to figure out how to resize the background when switching from portrait to landscape. Took me two hours just to figure out how to get the background upright when rotating but im using the grass file in the sample codes and when its rotated it doesnt fit the screen? How would i go about resizing it on the orientation change? Not sure if i need to use zoom? Could someone please point me in the right direction? Thank you! [import]uid: 14864 topic_id: 5727 reply_id: 305727[/import]
can’t you use something like
[code]
local stageHeight = display.contentHeight
local stageWidth = display.contentWidth
object.width = stageWidth
object.height = stageHeight
[/code] [import]uid: 9577 topic_id: 5727 reply_id: 19612[/import]
Thanks for the reply, slimboy. I tried it and while that does fill up the left and right spaces that were initially there it doesnt actually stretch the image. On the right it looks like some graphical error and on the left it looked like like a large piece of grass. Here is what i tried
local background = display.newImage ( “grass.png” )
local function onOrientationChange( event )
background.newImage = event.type
local direction = event.type
local newAngle = background.rotation - event.delta
transition.to( background, {time =20, rotation=newAngle} )
local stageHeight = display.contentHeight
local stageWidth = display.contentWidth
background.height = stageHeight
background.width = stageWidth
end
Runtime:addEventListener ( “orientation”, onOrientationChange )
[import]uid: 14864 topic_id: 5727 reply_id: 19615[/import]
anyone else have an idea? I’m simply just trying to get an image that seemed to be created for portrait to stretch out when changed to landscape mode. [import]uid: 14864 topic_id: 5727 reply_id: 19643[/import]
nvm lol i just resized the image to 480x320, I guess if im wanting a game to be in landscape i need to have the background designed in that resolution? [import]uid: 14864 topic_id: 5727 reply_id: 19645[/import]
I’d suggest higher for HD! [import]uid: 30374 topic_id: 5727 reply_id: 19842[/import]