yahiko Posted April 30, 2015 Share Posted April 30, 2015 I would like my mouse cursor to change over a specific sprite.Is there a way to do that? Link to comment Share on other sites More sharing options...
drhayes Posted April 30, 2015 Share Posted April 30, 2015 I can think of a couple of ways of doing that. 1. You could change the CSS cursor property of the canvas when the cursor is over a sprite, then change it back to "initial" once it's not over the sprite. But I *think* browsers are spotty on supporting custom cursors and certainly spotty when updating the cursor while still over the element whose declaration you're changing. 2. You could check out pointer lock and draw the cursor yourself based on the raw mouse data. Not sure how Phaser handles pointer lock, though, and it's experimental. 3. Draw a custom cursor under the regular OS cursor in your canvas. Link to comment Share on other sites More sharing options...
stauzs Posted April 30, 2015 Share Posted April 30, 2015 sprite.inputEnabled = true; sprite.events.onInputOver.add(function(){ this.game.canvas.style.cursor = "move"; }, this); sprite.events.onInputOut.add(function(){ this.game.canvas.style.cursor = "default"; }, this); jdnichollsc, Pooya72 and easierbycode 2 1 Link to comment Share on other sites More sharing options...
yahiko Posted April 30, 2015 Author Share Posted April 30, 2015 I figured out this solution at the same moment. Thank you anyway! Link to comment Share on other sites More sharing options...
qdrj Posted April 30, 2015 Share Posted April 30, 2015 This also can be done by useHandCursor property - http://phaser.io/docs/2.3.0/Phaser.InputHandler.html#useHandCursor sprite.input.useHandCursor = true; jdnichollsc and damien leroux 2 Link to comment Share on other sites More sharing options...
Recommended Posts