简体   繁体   中英

XNA/MonoGame Viewport how to use it

Well I've read different articles and questions on stackoverflow. But everyone suggests to use camera with viewport. Why just don't move viewport itself? AFAIK from SFML example things outside viewport won't be drawed. But with your implemented camera you have to control which things should be drawn. Isn't it better just to control viewport instead of camera?

Correct, Viewport methods are limited to what the viewing perspective of the user is. If you refer to "Viewport" you can ensure that the boundary will be directly within that range.

If you have an image that you are rendering to the screen, calling

Viewport.Width

will put your image directly outside of the viewing perspective.

You have to then do

Viewport.Width - myPicture.Width

for it to be viewable within the set boundaries.

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