Search the Community
Showing results for tags 'inputenabled'.
-
Sorry guys, I've just start using phaser, i wonder if it is possible for to create a line which is clickable? Here's the code function create(){ graphics = this.add.graphics(); graphics.lineStyle(20, 0x33FF00); graphics.moveTo(100,200); graphics.lineTo(300, 200); graphics.inputEnabled = true; graphics.input.useHandCursor = true; graphics.events.onInputDown.add(function(){ console.log('Clicked'); }); } When i use inputEnabled method, it works on most of other things like sprite or image, but for graphics it wont respond. I've look into the offical example provide by phaser web http://phaser.io/examples/v2/display/graphics-input-events i saw them adding graphics.input.useHandCursor = true; However for some reason it doesn't work like the example? Thank You so much for the time
-
Hi, I'm having an issue with a game ui I'm working on. I set up a number of sprites as buttons for a UI. They sit to the left of the screen and have event listeners associated with their onInputUp signals which fire correctly. Later in the user journey I create another sprite that sits below these interactive sprites and takes up the full size of the screen. This new sprite is also interactive (event listeners associated with both onInputUp and onInputDown fire correctly). HOWEVER, the new sprite blocks input events for the original sprites event though it visually sits below the full screen sprite. Does anyone have any idea what I'm doing wrong? I'm guessing I'm missing something vital about the way Phaser handles z-index and inputs? Interestingly if I .destroy() the full screen sprite the original sprites still remain unresponsive... weird! Thanks in advance!
- 4 replies
-
- input
- inputEnabled
-
(and 1 more)
Tagged with:
-
I am having issues trying to attach input events to a tile sprite. TileSprites extend Phaser Sprites, yet the inputEnabled property of Sprites is undefined on the TileSprite, and therefore does not run the input.start function to create the events when I set it to true. var corner = new Phaser.Sprite(game, 0, 0, 'corner');//corner.events contains null properties for the input events.corner.inputEnabled = true;//corner.events contains Phaser.Signals for the input events.corner.events.onInputDown.add(this.selectNextGem, this);//This worked, all good, carry on.var gemBox = game.add.tileSprite(0, 0, 128, 128, 'board');//gemBox.events contains null properties for the input events.gemBox.inputEnabled = true;//gemBox.events still contains null properties for the input events.gemBox.events.onInputDown.add(this.selectNextGem, this);//Exception thrown as onInputDown is null.Are TileSprites just not meant to have input love? EDIT: I guess not, because when I called input.start manually on the TileSprites input object and managed to get the input going, I was only able to fire off events by clicking in a region the size of the original sprite.
- 3 replies
-
- TileSprite
- Input
-
(and 2 more)
Tagged with: