Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

[TUTORIAL][XNA][C#] Using a custom mouse

Initiate Mage
Joined
Sep 12, 2012
Messages
21
Reaction score
1
To use a custom mouse you are drawing a sprite in the mouse location.

First in your Game class, declare your MouseTexture variable.
PHP:
public class Game : Microsoft.Xna.Framework.Game
    {
        GraphicsDeviceManager graphics;
        SpriteBatch spriteBatch;
        Texture2D MouseTexture;

In your LoadContent method import your sprite:
PHP:
  protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);
            base.LoadContent();
            MouseTexture = Content.Load<Texture2D>("bug-icon");
        }

And finally your draw method:
PHP:
protected override void Draw(GameTime gameTime)
        {
            spriteBatch.Begin();
            GraphicsDevice.Clear(Color.CornflowerBlue);
            base.Draw(gameTime);
            spriteBatch.Draw(MouseTexture, new Vector2(Mouse.GetState().X, Mouse.GetState().Y), Color.White);
            spriteBatch.End();
        }

There are other ways to do this, including calculating offset but this is the simplest method to do it.
 
Back
Top