Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var Label = function (x, y, textContent, fontStyle) {
// set a basic style
var style = fontStyle || {
font: '30px Arial',
fill: '#4488cc',
align: 'center'
};
// call the superclass method
Phaser.Text.call(this, game, x, y, textContent, style);
this.anchor.setTo(0.5, 0.5);
};
var Label = function (x, y, textContent, fontStyle) {
// set a basic style
var style = fontStyle || {
font: '30px Arial',
fill: '#4488cc',
align: 'center'
};
// call the superclass method
Phaser.Text.call(this, game, x, y, textContent, style);
this.anchor.setTo(0.5, 0.5);
};
Label.prototype = Object.create(Phaser.Text.prototype);
Label.prototype.constructor = Label;
module.exports = Label;
addLabel(text) {
const style = {
fill: Phaser.Color.getWebRGB(this.color),
font: '21px Open Sans'
};
const label = new Phaser.Text(this.game, 0, -30, text, style);
this.addChild(label);
}
createLabel(x, y, text) {
const { game } = this;
const style = {
font: '41px Open Sans',
fill: 'white',
align: 'center'
};
const label = new Phaser.Text(game, x, y, text, style);
label.setShadow(0, 2, 'rgba(0, 0, 0, 0.2)', 6);
label.anchor.setTo(0.5);
return this.addChild(label);
}