简体   繁体   中英

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); . 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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