jorge.graca Posted October 30, 2015 Share Posted October 30, 2015 Hi all, I am trying to extend the Phaser.Button to have different hit-areas depending on it's state:this.onInputDown.add(() => {this._isDown = true;let tempPhaserFrame = game.cache.getFrameByName(key, frameDown);if (tempPhaserFrame instanceof Phaser.Frame) {this.hitArea = tempPhaserFrame.getRect();// this.hitArea.offset(-this.anchor.x * this.hitArea.width, -this.anchor.y * this.hitArea.height);console.log(this.hitArea);}});However, when I do this the button immediately gets unpressed once the hitArea is changed. Why is this?How could I achieve a variable sized button hit check? Thanks. Link to comment Share on other sites More sharing options...
Skeptron Posted November 3, 2015 Share Posted November 3, 2015 Shouldn't you change the hit area on the input being UP instead? Link to comment Share on other sites More sharing options...
jorge.graca Posted November 3, 2015 Author Share Posted November 3, 2015 Hi Skeptron, Not really, it is just that the when the button is pressed it reduces it's size visually. I wanted to represent that in the hit box, so that when you drag out the mouse while not releasing the button, it would pop-out (became unpressed) at the new smaller edge instead of the bigger original edge. Does that make sense? Link to comment Share on other sites More sharing options...
Skeptron Posted November 3, 2015 Share Posted November 3, 2015 Then maybe this thread would help you : http://www.html5gamedevs.com/topic/18287-trying-to-figure-out-how-to-make-a-buttons-hitarea-defined-as-the-non-transparent-png-portion/ Link to comment Share on other sites More sharing options...
jorge.graca Posted November 3, 2015 Author Share Posted November 3, 2015 Thanks! That does indeed do what I wanted Just need to take care with the overhead created by constant pixel checking, thanks. Link to comment Share on other sites More sharing options...
Recommended Posts