XekeDeath Posted November 27, 2013 Share Posted November 27, 2013 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 notrun 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. Link to comment Share on other sites More sharing options...
rich Posted November 27, 2013 Share Posted November 27, 2013 Actually sorry this is a mistake on my part. TileSprite shouldn't extend Phaser.Sprite at all. I've updated the code and docs to remove this. The issue is that TileSprites work so differently from normal Pixi sprites that you simply can't extend them in the same way. Getting Input to work would require rewriting Pixi.TileSprite which I don't want to do right now, sorry. Link to comment Share on other sites More sharing options...
XekeDeath Posted November 27, 2013 Author Share Posted November 27, 2013 No worries Rich, I didn't feel like diving into Phaser to try sort it out either, so I settled for an invisible sprite over the top to act as my button. Link to comment Share on other sites More sharing options...
kstamatov85 Posted December 4, 2014 Share Posted December 4, 2014 No worries Rich, I didn't feel like diving into Phaser to try sort it out either, so I settled for an invisible sprite over the top to act as my button. Face the same issue and thought to solve the problem by same putting transparent sprite above the tileSprite. I worried if it is ok, but since it work for you, this is the workaround (: Cheers UPDATE: firstly I thought to use transparent png image to click on, but since some research I decide to use transparent bitmap and add it as sprite.Think this is better approach.var bmd = this.make.bitmapData(1080, 1920); //creates the BitmapData object var tabZone = this.add.sprite(0, 0, bmd);tabZone.inputEnabled = true;// add event listener to click/taptabZone.events.onInputDown.add(this.shootBullet, this); Link to comment Share on other sites More sharing options...
Recommended Posts