Libgdx:将2位演员彼此放置 [英] Libgdx: place 2 actors one on another

查看:131
本文介绍了Libgdx:将2位演员彼此放置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用libgdx的scene2d内置UI库在游戏中创建UI.我很有趣如何在一张桌子上一张一张地画两张图像(或演员)?我正在寻找类似Android中的 LayerDrawable 之类的东西.有没有可以制造的东西?

I use libgdx's scene2d built-in UI library to make an UI in my game. I'm interesting how can I draw 2 images(or actors) in a table one on another? I'm looking to the similar like LayerDrawable in Android. Is there any exists stuff to make it?

推荐答案

有一个 Stack 小部件.

更新:如果要将一个窗口小部件放置在另一个窗口小部件的上方,并且这些窗口小部件的大小不同,则应包装较小的窗口小部件.像这样:

UPDATE: if you want to place one widget on top of another widget and these widgets have different size then you should wrap the smaller widget. Something like:

//First add actual content
stack.add(content);

//Second add wrapped overlay object
Table overlay = new Table();
overlay.add(overlayWidget).expand().fillX().bottom().left();
stack.add(overlay);

stack变量是一个Stack实例

stack variable is a Stack instance

这是我项目的实际摘录.您应该针对自己的情况进行调整.

It's an actual excerpt from my project. You should tune it for your case.

这篇关于Libgdx:将2位演员彼此放置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆