A few weeks ago i was finally able to upload my first game to gamejolt.com so others could try and play it. The first feedback i received however, was the fact that the game wasn't working beyond the main menu.
I tried to replicate the problem and discovered the following. When i play the game on my own laptop in resolution 1366*768 (the resolution i developed in) everything works fine. However, when the game runs on a different resolution (1920*1080) the buttons i created won't activate when clicked. I fixed this by running the game in windowed mode (not fullscreen).
How can i have the game run in full screen mode on any resolution? And how can i know what resolution to use for each user? Or is this so complicated that it is advisable to run the game in windowed mode?
Below you can find my code for drawing my buttons and processing the clicks. Note that everything is working fine in the correct resolution.
Thank you in advance for your ideas and guidelines!
The relevant part of the drawing method
// Draws the button background
spritebatch.Draw(texture, DrawRectangle, sourceRectangle, Color.White);
The relevant code of the update methode
// Process clicks
Boolean mouseInDrawRectangle = DrawRectangle.Contains(new Point(world.MouseState.X, world.MouseState.Y));
// Mouse up on button
if (world.MouseState.LeftButton == ButtonState.Released && mouseInDrawRectangle == true)
if (state == Enums.ClickState.mousedown)
{
state = Enums.ClickState.selected;
buttonClicked = true;
}
else
state = Enums.ClickState.hoover;