Godot控制节点完全疯狂
我承认我已经使用了很长时间了,但我似乎无法获得控制节点来可预测。我已经能够接近,但没有颜色背景。我尝试添加一个殖民地,然后戈多完全变得笨拙。我不明白它如何获得这样的结果。我尝试了我能想到的所有随机组合。
左侧是带有菌落的破碎版本。右边的那个与我想要的东西一样近,但没有菌落。由于某种原因,菌落已完全蒸发。同样在左侧删除子节点并不能完全将其删除。在右边,孩子们正确地堆放在VboxContainer中,但在左侧,孩子们彼此叠放。该行是其自己的场景,其中包含一个儿童场景。那个场景是小时候的第一个场景。
我不知道如何解决此问题。
这是右边几乎有效的场景树。
这是添加背景颜色的许多尝试之一的场景树。
我希望有人知道该怎么做。
***编辑 是否有像jpanel一样工作的控件?有没有办法可以访问布局管理器?
***编辑 为什么容器中的布局管理器不像HboxContainer中的布局管理器那样工作?
***编辑 ColorBrickNode在Hbox的内部。 Hbox只有两个孩子。这两个孩子应该是Hbox宽度的一半。查看颜色的大小, + - 按钮是它的孩子。这应该如何工作?孩子如何在控制范围之外并仍然可以看到?
I admit I have not been using godot for very long but I cannot seem to get control nodes to act predictably. I have been able to get close but not with a color background. I tried adding a colorRect and then godot goes completely bonkers. I do not understand how it could have results like that. I have tried every random combination of controls I can think of.
on the left is a broken version with a colorRect. the one on the right is as close to what I want but does not have a colorRect. for some reason the colorrect has completely evaporated. also removing a child node on left does not remove it completely. on the right the children stack properly in the vboxcontainer but on the left, the children stack on top of each other. the row is its own scene, it contains a child scene. that scene has the first scene as children.
I have no idea how to troubleshoot this.
Here is the scene tree for the almost working one on the right.
here is the scene tree for one of the many attempts to add a background color.
I hope someone knows how to do this.
***EDIT
Is there a control that works like a jpanel? is there a way I can get access to the layout manager?
***EDIT
why does the layout manager in a Container not work like the layout manager in a hboxContainer?
***EDIT
ColorbrickNode is inside of an hbox. that hbox has only two children. those two children should be half of the width of the hbox. look at the size of colorbrickNode, the +- buttons are children of it. how should this be working? how can children be outside of the confines of a control and still be visible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我得到了它。我使用了边距容器。为什么保证金容器具有功能,但没有香草容器?谁知道。当每个容器都有设置边距的能力时,为什么有保证金容器?谁知道。保证金容器具有设置孩子大小的能力。保证金容器的能力可以让孩子组件彼此堆叠。保证金容器应为默认容器。这个名字非常误导。它不是图形完美的,但非常接近。
I got it. I used a margin container. why does a margin container have the functionality but a vanilla container does not have? who knows. why is there a margin container when every container has the ability to set margins? who knows. A margin container has the ability to set the size of its children. a margin container has the ability to have children components stack on top of each other. a margin container should be the default container. the name is very misleading. it is not graphicaly perfect but it is very close.
我想我理解这个问题。至少为什么
colorrect
转向一行。我假设您将其布局设置为“完全矩形”,对吗? 猜测。,但您尚未设置其大小标志。当容器内的
colorrect
时,该容器将决定其大小和定位的方式。在这种情况下,容器是hboxContainer
,对吗? 我不确定您在哪里添加实例,我猜在这里。hboxContainer
将把孩子设置为列。因此,他们占据了整个高度,正如我们看到colorrect
做的那样。并确定所需的水平空间……好吧,它尽可能少,因此您会得到一条线。另一方面,
vboxContainer
colorrect
的大小最小。因此,它溢出了colorrect
。 是的,我们可以想象可以根据其内容设置其最小尺寸……除了container
。 (例如
hboxContainer
)要使孩子的大小不同,您将设置所述孩子的尺寸标志。我已经介绍了
控制
s的定位和大小。 >和在这里。I think I understand the issue. At least why the
ColorRect
turns to a line. I'm assuming you have set its layout to "Full Rect", right? Guessing. But you have NOT set its size flags.When the
ColorRect
inside a container, that container is what will dictate how it is sized and positioned. In this case the container is aHBoxContainer
, right? I'm not sure where you are adding the instances, I'm guessing here. AHBoxContainer
would set its children as columns. So they take the full height, as we see theColorRect
do. And to decide how much horizontal space it takes… Well, it takes as little as possible, so you get a line.The
VBoxContainer
inside theColorRect
, on the other hand, has a minimum size. So it overflows theColorRect
. Yes, we could imagine that could set its minimum size based on its contents… Except, it is notContainer
.Now, to tell a
Container
(such as theHBoxContainer
) to size its children differently, you would set the size flags of said children.I have covered how
Control
s are positioned and sized in more detail in other answers here and here.