|
-
Aug 9th, 2009, 10:46 AM
#1
Thread Starter
Addicted Member
[RESOLVED] Screen Resolution
I'm looking for some advice on how to make my app work with different resolutions as I have posted a demo game on the forum but the game was designed on my laptop which is set to 1280x800 but a few people who have tried the demo are having problems as they are using 1024x768.
Is this a case of getting the computers resolution when the app starts and alter the size and position of controls?
Any help is appreciated.
-
Aug 9th, 2009, 11:56 AM
#2
Re: Screen Resolution
Yes - Games should be able to adjust to the size of the screen. Scale and reposition the items based on the screen size.
-
Aug 9th, 2009, 12:14 PM
#3
Re: Screen Resolution
Since your game is based on a play-area that is of a defined size, why not just create a form that is the proper size, instead of attempting to make it full screen?
-
Aug 9th, 2009, 01:02 PM
#4
Thread Starter
Addicted Member
Re: Screen Resolution
But what if I want it full screen? For the demo that I have published I can resize the form but the current project I am working on has been designed to be full screen.
Can anyone advise on how to go about sorting out this problem?
How can I work out how the graphics need to be resized?
-
Aug 9th, 2009, 01:27 PM
#5
Re: Screen Resolution
Are you using DirectX or just regular forms and screen manipulation?
If you're not using DirectX, My.Computer.Screen.WorkingArea returns a rectangle that gives you the working area of the screen (ie the resolution of the screen, less fixed items like docked toolbars etc).
In terms of sizing things, again it depends on what method you are using, but if you have all your current code set up to position items based on a set screen size you could simply work out x and y ratios of the actual screen size compared to the base screen size, and factor all positions by the x and y ratios.
-
Aug 9th, 2009, 01:34 PM
#6
Thread Starter
Addicted Member
Re: Screen Resolution
I'm using XNA and the XNA game object rather than a form
-
Aug 9th, 2009, 01:36 PM
#7
Re: Screen Resolution
Well so everything you draw must be in relation to the screen and its size. There is nothing more to it.
Use Me.graphics.GraphicsDevice.ViewPort to retrieve information about the screen.
-
Aug 9th, 2009, 02:36 PM
#8
Thread Starter
Addicted Member
Re: Screen Resolution
But I don't really understand.
Say I have the frame of my game board which was created based on a resolution of 1280x800 and has the following properties:
Height: 375
Width: 250
X: 200
Y: 200
If I detect that the users resolution is 1024x768 then how do i work out the new size and location for this rectangle?
-
Aug 9th, 2009, 02:43 PM
#9
Re: Screen Resolution
If you on a 1280x800 surface have a 250x375 frame, then the calculate the proportions like so:
250 / 1280 = 0.195
375 / 800 = 0.469
Now you'd just set the frames width to 0.195 * Me.graphics.GraphicsDevice.ViewPort.Width and the height to 0.469 * Me.graphics.GraphicsDevice.ViewPort.Height.
The X and Y coordinates would be done in the same way:
200 / 1280 = 0.156
200 / 800 = 0.25
Set the X coordinate to 0.156 * Me.graphics.GraphicsDevice.ViewPort.Width and the Y coordinate to 0.25 * Me.graphics.GraphicsDevice.ViewPort.Width.
I think thats the best way of going about it, altough I'm relatively fresh with XNA aswell.
-
Aug 9th, 2009, 02:56 PM
#10
Thread Starter
Addicted Member
Re: Screen Resolution
Ok cool I shall give that a go, thanks
-
Aug 9th, 2009, 03:05 PM
#11
Thread Starter
Addicted Member
Re: Screen Resolution
Would I have to create different size images aswell for each resolution setting?
-
Aug 9th, 2009, 03:47 PM
#12
Thread Starter
Addicted Member
Re: Screen Resolution
Have just tried what you said and it works perfect. If the screen setting is 800x600 it does distort the graphics slightly but I don't suppose many people use 800x600 any more.
Just gotta go through all my graphics and text and alter the size and positions.
Thanks again for the help
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|