简体   繁体   English

libgdx相机视口的用途

[英]libgdx purpose of viewport with camera

I often see in tutorials that people create a camera and pass that to the viewport, like so viewport = new FillViewport(100,100,camera); 我经常在教程中看到人们创建了一个相机并将其传递给视口,例如viewport = new FillViewport(100,100,camera); . Why isn't just creating a viewport not enough? 为什么仅创建视口还不够? Doesn't it automatically create a camera? 它不是自动创建相机吗?

Thanks 谢谢

创建相机可以让您四处走动,大多数示例都可以做到。

You generally don't need to separately instantiate a camera. 通常,您不需要单独实例化摄像机。 Most tutorials I've seen do not exclusively follow best practices, so keep that in mind when you read them. 我见过的大多数教程并不只遵循最佳实践,因此在阅读它们时请记住这些。 But in this case, it's just preference. 但是在这种情况下,这只是偏好。 You will probably want to get a reference to the viewport's camera regardless, so you can manipulate its position. 无论如何,您可能都希望获得对视口相机的参考,以便您可以操纵其位置。

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

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