17 lines
506 B
JavaScript
17 lines
506 B
JavaScript
const { TEXT, POSITIONS: { STATS } } = require('./constants');
|
|
|
|
const menuHeight = STATS.height() * 0.1;
|
|
const menuWidth = STATS.width() * 0.25;
|
|
|
|
function addButton(scene, x, y, cback, name) {
|
|
const button = scene.add
|
|
.rectangle(x, y, menuWidth, menuHeight, 0x222222)
|
|
.setInteractive()
|
|
.setOrigin(0)
|
|
.on('pointerdown', cback);
|
|
scene.add.text(button.getCenter().x, button.getCenter().y, name, TEXT.HEADER)
|
|
.setOrigin(0.5, 0.5);
|
|
}
|
|
|
|
module.exports = addButton;
|