@shniqq wrote:
Hello community!
I have a simple thing, that I can't get to work: I want to center the mouse at the game windows center point.
Mouse.SetPosition(graphics.PreferredBackBufferWidth/2, graphics.PreferredBackBufferHeight/2);
I thought it would work like this, but it doesnt! My cursor gets sent to the bottom of screen (not all the way down, but nearly) and on the X axis its exactly at the center of the game window (as it should be).
Games resolution is set to 1024x576.I used this for testing:
`using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Storage;
using Microsoft.Xna.Framework.Input;namespace MonoGameTest
{
///
/// This is the main type for your game.
///public class Game1 : Game { GraphicsDeviceManager graphics; SpriteBatch spriteBatch; public Game1 () { graphics = new GraphicsDeviceManager (this); Content.RootDirectory = "Content"; } protected override void Initialize () { IsMouseVisible = true; graphics.PreferredBackBufferWidth = 1024; graphics.PreferredBackBufferHeight = 576; graphics.ApplyChanges (); base.Initialize (); } protected override void LoadContent () { spriteBatch = new SpriteBatch (GraphicsDevice); } protected override void Update (GameTime gameTime) { Mouse.SetPosition (graphics.PreferredBackBufferWidth / 2, graphics.PreferredBackBufferHeight / 2); Console.WriteLine ("Position: " + Mouse.GetState ().Position.ToString ()); base.Update (gameTime); } protected override void Draw (GameTime gameTime) { graphics.GraphicsDevice.Clear (Color.CornflowerBlue); base.Draw (gameTime); } }
}
`It logs the correct position...
Position: {X:512 Y:288}
Did I misunderstood a basic principle here, or is this a bug?
MonoGame is Version 3.5.1.1679Hope someone can explain this unexpected behavior to me..
Posts: 3
Participants: 2