san40511 Posted April 28, 2015 Share Posted April 28, 2015 Hello guys. I have a question. How I can add active state to button? For example we have the button and I'm click to this button - I need to change current sprite to another(active state). After repeat click I need to change sprite to normal state. Thanks for help. Link to comment Share on other sites More sharing options...
MichaelD Posted April 28, 2015 Share Posted April 28, 2015 The button class already has arguments for over, out, down, up so you can use: Info here: http://phaser.io/docs/2.3.0/Phaser.Button.htmlgame.add.button(0, 0, 'play', 'play', 'play-down', 'play', this.startGame, this); Link to comment Share on other sites More sharing options...
san40511 Posted April 30, 2015 Author Share Posted April 30, 2015 no. I need button with active state. It must stay pushed after mouse click Link to comment Share on other sites More sharing options...
MichaelD Posted April 30, 2015 Share Posted April 30, 2015 You can set the "Up" state to have the same graphic as the down state since -> 'Up' - when the Pointer that was pressed down on the Button is released again And when you want the original frame you could do button.frame = 0; Link to comment Share on other sites More sharing options...
grumpygamer Posted May 1, 2015 Share Posted May 1, 2015 Might be talking rubbish here, but I think you might be able to add property "active" to the Phaser.button class:https://github.com/photonstorm/phaser/blob/master/src/gameobjects/Button.js or maybe just add the active state to your button instance:b = game.add.button(...);b.active = true; Link to comment Share on other sites More sharing options...
Recommended Posts