I’m using Monogame 3.7.1.189 and I’m trying to set a custom mouse cursor using MouseCursor.FromTexture2D, but the texture comes out scrambled.
Here is the relevant code.
public Game1()
{
graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = “Content”;
this.IsMouseVisible = true;
}
/// <summary>
/// Allows the game to perform any initialization it needs to before starting to run.
/// This is where it can query for any required services and load any non-graphic
/// related content. Calling base.Initialize will enumerate through any components
/// and initialize them as well.
/// </summary>
protected override void Initialize()
{
// TODO: Add your initialization logic here
base.Initialize();
}
/// <summary>
/// LoadContent will be called once per game and is the place to load
/// all of your content.
/// </summary>
protected override void LoadContent()
{
// Create a new SpriteBatch, which can be used to draw textures.
spriteBatch = new SpriteBatch(GraphicsDevice);
_texture = Content.Load<Texture2D>("finger_pointer");
Mouse.SetCursor(MouseCursor.FromTexture2D(_texture, 0, 0));
// TODO: use this.Content to load your game content here
}
When I run the game, the cursor looks like this:
When it should look like this:
How can I get the pointer to display correctly?