Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
Fit width scale mode question? — Gideros Forum

Fit width scale mode question?

hnimhnim Member
edited July 2012 in Bugs and issues
hi everyone,
im using fit width scale mode in my project. when i change emulator resolution, it seems [top,left] move up a bit. Is this bug of feature? How long does it change?
thanks

Likes: Learner

+1 -1 (+1 / -0 )Share on Facebook

Comments

  • ar2rsawseenar2rsawseen Maintainer
    It does exactly what it's supposed to. It fits width of screen by cropping or extending height of the screen. In your case height needs to be cropped.

    You are probably looking for a letterbox scale mode

    Likes: atilim

    +1 -1 (+1 / -0 )Share on Facebook
  • hnimhnim Member
    edited July 2012
    thanks, but i want to keep my game full screen, so it seems letterbox is not good solution for me. So i try to calculate padding value to re-arrange my sprite on screen, but there is no luck :(
    i supposed our game-view is center-align:
    application:setOrientation(Application.LANDSCAPE_LEFT)
    application:setBackgroundColor(0x66cc00)
    -------------------------------------------
    local deviceWidth = application:getDeviceWidth()
    local deviceHeight = application:getDeviceHeight()
     
    local SCREEN_WIDTH = application:getContentWidth()
    local SCREEN_HEIGHT = application:getContentHeight()
     
    local orientation = application:getOrientation()
    if orientation == Application.LANDSCAPE_LEFT or orientation==Application.LANDSCAPE_RIGHT then
    	local t = deviceWidth
    	deviceWidth = deviceHeight
    	deviceHeight = t
    end
     
    local topPadding = -(deviceHeight - (deviceWidth/SCREEN_WIDTH)*SCREEN_HEIGHT)/2
     
    local circleTx = Texture.new("circle.png", true)
     
    local circle1 = Bitmap.new(circleTx)
    circle1:setPosition(0, topPadding)
    stage:addChild(circle1)
    any suggest?
    thanks a lot
    demo2.png
    278 x 286 - 9K
  • ar2rsawseenar2rsawseen Maintainer
    edited July 2012
    I suppose what you don't like at letterbox is the offset, but well this is how it goes, if you do not want to stretch image to cover whole screen, then you either crop longest sides or make offsets for shorter ones.

    In my projects I use "letterbox" scaling mode together with absolute positioning to fill in the blanks:

    http://appcodingeasy.com/Gideros-Mobile/Ignore-Automatic-Screen-Scaling-when-positioning-objects

    Likes: hnim, atilim

    +1 -1 (+2 / -0 )Share on Facebook
  • atilimatilim Maintainer
    edited July 2012
    @ar2rsawseen, I realized that my formulation is a little bit different then yours:
    local ltx = application:getLogicalTranslateX()
    local lty = application:getLogicalTranslateY()
    local lsx = application:getLogicalScaleX()
    local lsy = application:getLogicalScaleY()
    local dw = application:getDeviceWidth()
    local dh = application:getDeviceHeight()
    local orientation = application:getOrientation()
     
    if orientation == Application.LANDSCAPE_LEFT or orientation == Application.LANDSCAPE_RIGHT then
    	dw,dh = dh,dw
    end
     
    -- top left
    local startx = -ltx / lsx
    local starty = -lty / lsy
     
    -- bottom right
    local endx = (dw - ltx) / lsx
    local endy = (dh - lty) / lsy
    Because in "no scale" mode, logical dimensions (and hence content dimensions) are not used and therefore I need to use device dimensions to do the calculations.

    anyway, mine and yours are identical for all scaling modes except "no scale".

    Likes: johnyc100

    +1 -1 (+1 / -0 )Share on Facebook
  • ar2rsawseenar2rsawseen Maintainer
    actually @atilim, what you call my formulation, is actually your formulation :D

    Yeah, I was thinking about compliance with no scaling, but since I'm always using letterbox mode it worked perfectly and is much shorter :)
  • atilimatilim Maintainer
    ohh really :)
    and letterbox is also my favorite (and sometimes fit width/fit height)
Sign In or Register to comment.