It looks like you're new here. If you want to get involved, click one of these buttons!
function scene:rectangularShape(x, y, width, height, fillTexture) local rectangle = Shape.new() if fillTexture then rectangle:setFillStyle(Shape.TEXTURE, fillTexture) end rectangle:beginPath() rectangle:moveTo(-width/2,-height/2) rectangle:lineTo(width/2, -height/2) rectangle:lineTo(width/2, height/2) rectangle:lineTo(-width/2, height/2) rectangle:closePath() rectangle:endPath() rectangle:setPosition(x,y) return rectangle end function scene:init() local screenW = application:getContentWidth() local screenH = application:getContentHeight() local background = self:rectangularShape(screenW/2, screenH/4, screenW, screenH, Texture.new("background.png")) stage:addChild(background) end |
Dislikes: beunn
Comments
This will scale the image in landscape mode - with Scale set to stretch or other scaling mode in project properties
cheers
evs
why don't you use auto scaling?
Simply set logical sizes (smallest first and greatest second = 768 x 1024) of your background image and set scaling to Letterbox and it should look fine in same orientation in different resolutions.
Likes: MikeHart
@ar2rsawseen: I'll try autoscaling too. But it'll have to wait until later when I have time. Thanks for all the good advice!
gameBackground.png - 512x320
gameBackground@1.5x.png - 1024x640
gameBackground@2x.png - 1280x800
Then in the project properties I set:
Scale Mode: Letterbox
Logical Dimensions: 320 x 480
Image Scales:
@2x - 2
@1.5x - 1.5
So far this looks great on my tablet and phone.
If you use a different scaling you'll want to check out the different aspect ratios of various devices to make sure you have enough bleed room so the important parts don't get cut off.
[edited: mistyped 1200 instead of 1280]
Dislikes: tytadas
If you want to use Crop you'll loose part of the background so you need to leave an area which has more of the background but has parts that can be cut off. I use this template (based off a 1280x800 screen) to do that: http://www.nevermorelabs.com/share/bleedTemplate.png The white area is the area that will be visible across all devices and the grey areas are those that might get cut off. The white area is 1067x720.
I created this based of the aspect ratios for various devices. I've compiled a spreadsheet here of a bunch of devices which is open to the public to tweak: http://goo.gl/VVZ1u