I could create a parent node set it at the width of the screen and use X Anchor on that. But that only solved the X (and gives me an extra node which is bad in GUI heavy scenes, because you could hypothetically run out). How can I make it in the correct place in Y?
What the logic: inv_panel is Stretch node, that mean that his node has dynamic size depends on resolution.
What is the anchor point in case when size could be changed? Top right corner of this panel (because our button position should be static relative to this corner).
That means that we need to add a point in top right corner that will be pinned there (or respect the same rules, as a panel node)
That why I added this respect_parent node in this corner.
Last thing here: set position of our button inside this new node (we have to turn off anchors for this button)
or…
Defold needs more flexible pivot point system with vector3 pivot point (that applies negative pivots too) instead of “side of the world” system. But, unfortunately, for now, it’s out of our near future plans, as I know. @britzl knows more
Got another questions about Adjustment modes and anchoring
I have a fairly complex scene, which I want to scale in a certain way. But I just can’t figure out a way to do it. Is it possible to do with Adjustment modes and Anchoring? Or do I need to do it manually in code?
In this case, you wanna use “fit” for the position and “stretch” for size and I don’t know how to do that ( (maybe @britzl know?)
I have only one idea: to use “fit” for your scroll list for the position and calculate/set the size of the stencil node manually.
local stencil_node = gui.get_node("stencil")
local layout_size = vmath.vector3(720, 1280, 0) -- your layout size
local screen_size = vmath.vector3(570, 1155, 0) -- Hardcoded for simplicity, but it should be: (render.get_window_width(), render.get_window_height(), 0)
local sx, sy = screen_size.x / layout_size.x, screen_size.y / layout_size.y -- scale coef for x and y
local fit = math.min(sx, sy) --a fit scale coefficient
local node_size = gui.get_size(stencil_node) -- get current size
node_size.y = node_size.y/fit * (1/sy) -- when we divide by fit we canceling a fit transformation and then apply a stretch by multiplying (1/sy)
gui.set_size(stencil_node, node_size)