makotok/Hanappe

Add ability to set scaleX and scaleY separately for viewport in flower

Vavius opened this issue · 7 comments

Maybe, viewport handling should be redone in flower.
Now it forces to use coordinate system where y = 0 at top.

While that setting is OK for GUI-intensive apps, it's not very suitable for physics games, platformers, and such.

Maybe we could find a solution? Problem seems pretty hard, since all widgets and probably other extensions are coordinate system dependent. Also, all texture coordinates should be flipped as well.

Viewport can be set up individually.
A GUI layer sets up standard viewport.
A physical layer sets up viewport with an arbitrary mounting person.

All standard MOAI functions can be used.
Flower should be made as it is.

Is a texture possibly reversed?

Only coordinates can be made into a standard at the center.
In that case, a texture should not be reversed.

Setting viewports for different layers can be acceptable workaround.

But texture is flipped vertically. It is a UV coordinates issue. Default uv
rect is (0, 1, 1, 0), flower uv rect is (0, 0, 1, 1)

When the center coordinates.

local viewport = MOAIViewport.new()
viewport:setSize(flower.screenWidth, flower.screenHeight)
viewport:setScale(flower.viewWidth, -flower.viewHeight)

So, I cannot invert Y axis direction, i.e. 0 at bottom 480 at top?

local viewport = MOAIViewport.new()
viewport:setSize(flower.screenWidth, flower.screenHeight)
viewport:setScale(320, 480)

If I understand it correctly, UV coordinates should be flipped too.

Understood.
It may be so indeed.

For 2D games, towards the standard would be easy to use top left Viewport.
Starling, even CoronaSDK, Viewport is a standard top left.

However, we will should be able to select the Viewport different.
Should I use the Viewport another might say the physical.

This problem can be solved DisplayObject If you can reverse?
For example, I implement the flip function.

The default viewport options have been added.