Skip to content

Latest commit

 

History

History
107 lines (78 loc) · 2.67 KB

button.md

File metadata and controls

107 lines (78 loc) · 2.67 KB

Button

Kind: global class

new Button(game, x, y, width, height, color, clickAction)

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() } )

button.hide()

Hides the button

Kind: instance method of Button

button.setText(text, textColor, fontFamily)

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")

button.setImage(image)

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')

button.show(reverse)

Shows the button

Kind: instance method of Button

Param Type Description
reverse Boolean If true then show clicked down button

button.on(event, handler)

Adds an Event Listener

Kind: instance method of Button

Param Type
event string
handler function

button.off(event, handler)

Removes an Event Listener

Kind: instance method of Button

Param Type
event string
handler function