Kind: global class
An easy way to make a working button that shows both up and down clicks and is very easy to use.
Param | Type | Description |
---|---|---|
game | Phaser.Scene |
|
x | Number |
|
y | Number |
|
width | Number |
|
height | Number |
|
color | string |
Must be of the format '0x123123' |
clickAction | function |
Example
const pauseButton = new Button(scene, 0, 100, 500, 100, '0xff1234', () => { myGame.pause() } )
Hides the button
Kind: instance method of Button
Sets text for the button
Kind: instance method of Button
Param | Type | Description |
---|---|---|
text | string |
|
textColor | string |
must be of the format '#abcd12' |
fontFamily | string |
css font family value |
Example
pauseButton.setText("Pause", "#ff5666", "Roboto")
Sets an image for the button
Kind: instance method of Button
Param | Type | Description |
---|---|---|
image | string |
An image loaded into phaser |
Example
settingsButton.setImage('Settings Image')
Shows the button
Kind: instance method of Button
Param | Type | Description |
---|---|---|
reverse | Boolean |
If true then show clicked down button |
Adds an Event Listener
Kind: instance method of Button
Param | Type |
---|---|
event | string |
handler | function |
Removes an Event Listener
Kind: instance method of Button
Param | Type |
---|---|
event | string |
handler | function |