Sign in to follow this  

XNA viewport zoom

This topic is 3204 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am making a 4 player 2d game, and want 4 viewports on one screen. Each player will see a half scaled version of the game in their quarter (Eg, circles or radius 16 become radius 8) If I set the viewport Height and Width to half screen height and width and leave the viewport X and Y as 0, it draws a viewport in the top left corner of the screen. All of the sprites are regular sized, but when I draw primatives, they are scaled to one quarter of their size and position. However, if I set the viewport X and Y to halfscreen width and height, but leave the viewport width alone, something different happens. The scene is drawn the same as a fullscreen viewport, but with everything, txt, sprites and all, scaled down to half size. This is the effect that I want for all 4 corners. At the moment I stumbled across how to get it to zoom out to half on the bottom right corner just by changing the viewportX and Y and leaving everything else alone. It's like it had to zoom out to squeeze everything to fit, and this is exactly what I want for the other 3 viewports. I'm using a 3rd party class PrimativeBatch to draw my primatives, and would rather not have to learn about transformations if I can avoid it, seeing as it looks like XNA has figured it out once by itself already! Any ideas how to go about this? [Edited by - CIJolly on March 11, 2009 7:22:08 PM]

Share this post


Link to post
Share on other sites
After a lot of searching, I never found how to to simply and automatically scale the entire screen the way the program did when I set the position to half the screen dimensions and didn't change the width.

I ended up simply scaling all sprites and positions by whatever the zoom was. A little more ugly and a little more work, but it worked. I would still be interested to know if there is a coding solution to the problem, seeing as somewhere along the line it must know how to scale the view automatically, as that's what it does by default in one situation.

Share this post


Link to post
Share on other sites

This topic is 3204 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this