mkit Posted February 5, 2015 Share Posted February 5, 2015 Just getting to grips with the basics of Phaser (Phaser v2.2.2) and trying to make a simple memory game. I am experiencing problems turning off the hand cursor on a sprite. I am using the following code:setEnabledStateOfCards: function(boolState) { var numCardObjects = this.arrCards.length; for (var i = 0; i < numCardObjects; i++) { this.arrCards[i].inputEnabled = boolState; this.arrCards[i].input.useHandCursor = boolState; }}this.setEnabledStateOfCards(false);I am testing in Firefox on Windows 8. I have noticed after setting useHandCursor to false, it does not change back to the arrow cursor but remains a hand even if I move the mouse in and out of the sprites. If however I alt tab away from the page and then return to the page the cursor has then updated correctly. Are you aware of any bug related to this functionality? Link to comment Share on other sites More sharing options...
mkit Posted February 11, 2015 Author Share Posted February 11, 2015 Nobody else experience this issue? Here is a link to a simple file illustrating the issue. http://wvcv.com/phaser/testCursor.html Clicking on the button should turn the hand cursor off. This does not happen until I alt-tab away from the browser tab or window and then return. Here is the full code for this test file:<!DOCTYPE HTML><html><head> <meta charset="UTF-8" /> <title>Cursor Test</title> <script src="js/phaser.min.js"></script> </head><body style="margin:0px;" bgcolor="#000000"><div id="gameContainer"></div><script type="text/javascript">window.onload = function() { var game = new Phaser.Game(900,600, Phaser.AUTO, 'gameContainer', { preload: preload, create: create }); var image; function preload () { this.load.image('card', 'assets/cardFront4Daisy.png'); } function create () { image = this.add.sprite(game.world.centerX, game.world.centerY, 'card'); image.inputEnabled = true; image.input.useHandCursor = true; //if you want a hand cursor image.events.onInputDown.add(startGame, this); } function startGame() { //alert ("startGame"); image.input.useHandCursor = false; }};</script></body></html>It is frustrating getting stuck on something so basic so would be helpful to know if I am just being dumb or if there is a genuine bug here? Thanks Link to comment Share on other sites More sharing options...
rich Posted February 23, 2015 Share Posted February 23, 2015 useHandCursor = false won't reset the pointer. It will just tell Phaser to not try and set it again when you next mouse-over that image. It will automatically turn it off when you move the mouse away from the image. Or you can override it directly with:this.game.canvas.style.cursor = "default"; Link to comment Share on other sites More sharing options...
mkit Posted February 26, 2015 Author Share Posted February 26, 2015 Thanks Rich for the reply Unfortunately the functionality you indicate should occur does not happen in the example I provided: http://wvcv.com/phaser/testCursor.html When the image is clicked it calls the following code.image.input.useHandCursor = false;You stated "It will automatically turn it off when you move the mouse away from the image. " It would do that anyway without my code as I have only set the useHandCursor for the image. What I wanted it to do is turn off when you move the mouse away from the image and then move it back on to the image. This does not appear to happen. The following code you suggested surely just turns the cursor off for the entire game. I am making a card game and I need to disable the hand cursor on individual cards.this.game.canvas.style.cursor = "default";Thanks Paul Link to comment Share on other sites More sharing options...
KaW Posted April 15, 2016 Share Posted April 15, 2016 Hi, I'm having the same issue described here with 2.4.6. After hitting a button, the button does: button.inputEnabled = false; button.input.useHandCursor = false; button.alpha=0.5; Everything is set as it should except for the hand that stays on and refuses to leave even while moving the mouse. I have to put the cursor over another button in order for it to get back to normal. Any ideas on how to fix this or why might be happening? Thanks! Edit: Still happening. It caused when the button is disabled while the cursor is on it. Link to comment Share on other sites More sharing options...
joeyl Posted March 14, 2017 Share Posted March 14, 2017 Hello, A solution to this issue is to disable the input all together. button.inputEnabled = false; This inherently disables the useHandCursor, and to toggle it back on you would simply reenable the button and hand cursor. button.inputEnabled = true; button.input.useHandCursor = true; Hope this helps. Link to comment Share on other sites More sharing options...
Recommended Posts