makotok / Hanappe

Hanappe is a game framework for MOAI SDK.
Other
107 stars 41 forks source link

Flower Widgets and viewScale not playing nicely #94

Closed JacobFischer closed 11 years ago

JacobFischer commented 11 years ago

I've noticed some odd behavior of the Widgets when you set the viewScale to be very large. Using the example code in Hanappe/projects/flower-extensions/samples/ and doing the following changes:

config.lua @ line 12-15

local tilesX = 16
local screenWidth = MOAIEnvironment.horizontalResolution or 320
local screenHeight = MOAIEnvironment.verticalResolution or 480
local viewScale = screenWidth / tilesX

main_scene.lua Replace the whole file with:

module(..., package.seeall)

function onCreate(e)
    view = widget.UIView {
        scene = scene,
    }

    textbox = widget.TextBox {
        size = {5, 5},
        text = "Hello",
        textSize = 2,
        parent = view
    }
end

This makes a 320x480 pixel window, with the viewport set such that 1 internal unit = 20 pixels (320/16). This way in tile based games the resolution will not matter and objects can display relative to tiles, not pixels. So the code should show a textbox with the text "Hello" inside it, but instead I get this:

I think that is because the 9-patch isn't scaling with the viewScale properly. This behavior of the text being pushed out of the graphic also happens with Buttons. In addition shouldn't the 9-patch always have it's corners pixel perfect while stretching the middle? Instead here you can see the corners are being scaled too.

Also, if you instead make an ImageButton it isn't scaled to that size at all:

You can see the first few pixels of it in the corner, it's huge.

So it appears to me that the widget extension doesn't like viewScales other than 1. Is there any way to fix this?

Other than this, the flower library is amazing so far to me.

makotok commented 11 years ago

This has occurred for too large viewScale.

Might not work well with the smaller the image size of the original NineImage. Padding may become negative.

there is no problem viewScale is in the range of 1 ... 4. More is not practical image becomes too rough.