Jump to content

How do I replace the mouse cursor with a sprite?


madmuffin
 Share

Recommended Posts

I looked through the examples and searched online but I can't find anyone else having ever done this to use as an example;

I'm trying to hide the default computer mouse pointer and replace it with a sprite in my game that is very reactive; eg changing to different art depending on what you're mousing over or if you're giving and order or something.

Does anyone have an example of this I could look at?

Link to comment
Share on other sites

I think you can deactivate the mouse crusor like this

<canvas width="800" height="600" style="display: block; cursor: none;"></canvas>

Then you can add an move callback to the game input manager like this

game.input.addMoveCallback( function(pointer, x, y) {
   // pointer is the active pointer, x and y give you the position of the pointer
   // on the canvas so here you can position you custom cursor sprite
});

Didn't test it but I think it should work

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...