简体   繁体   English

有没有适当的方法来扩大舞台上的演员人数?(Libgdx)

[英]Is there a proper way to scale actors on the Stage?(Libgdx)

I'm making an android app which has Libgdx Stage handling the HUD. 我正在制作一个具有Libgdx Stage处理HUD的android应用。 But how can I scale things I add to Stage? 但是如何缩放添加到舞台的内容?

I've tried some manipulations with Camera, Viewport, and none of the work properly. 我已经尝试过使用Camera,Viewport进行一些操作,但都无法正常工作。 Let's say I want my ImageButton placed in the right top corner of the screen. 假设我要将ImageButton放置在屏幕的右上角。 I managed to do that manipulating with table positioning, it seems to be fine. 我设法通过表定位进行操作,这似乎很好。 But the problem appear when I run my app on my phone. 但是当我在手机上运行我的应用程序时出现了问题。 The ImageButton positioned right but it's kinda small :-) ImageButton位置正确,但有点小:-)

Thing is I want ImageButton look like on (540,800) resolution screen. 我想让ImageButton在(540,800)分辨率屏幕上看起来像。 ImageButton is (65,65). ImageButton为(65,65)。 When it comes to bigger screensizes ImageButton starts to look small because it does not scale(or the viewport and camera stuff dont work well, I dont think the actual scaling is truly necessary) 当涉及到更大的屏幕尺寸时,ImageButton开始缩小,因为它无法缩放(或者视口和相机的东西不能正常工作,我认为实际缩放没有必要)

I suggest you to check the documentation about Viewports, which is pretty clear, although a bit dated : https://github.com/libgdx/libgdx/wiki/Viewports 我建议您检查有关视口的文档,这虽然很陈旧,但很清楚: https : //github.com/libgdx/libgdx/wiki/Viewports

If you don't need to mess with the camera, don't bother to declare one. 如果您不需要弄乱相机,也不必费心声明一个。 Simply use a stage, with includes automatically an orthographic camera. 只需使用一个舞台,即可自动包括一个正交摄影机。 If you declare an Actor within the bounds of the viewport, it should scale properly depending on the type of viewport you selected. 如果在视口范围内声明Actor,则它应根据所选视口的类型正确缩放。 For instance : 例如 :

FillViewport vp = new FillViewport(800, 1280); // fills the screen, adapting itself to actual screen ratio
Stage stage = new Stage(vp);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM