83 lines
2.0 KiB
JavaScript
83 lines
2.0 KiB
JavaScript
/////////////////////////////
|
|
// Screen bottom
|
|
|
|
class ScreenBottom {
|
|
|
|
constructor() {
|
|
this.dbConnectManager = new DBConnectManager();
|
|
|
|
this.bottomBarCenterY = game.world.height - ScreenBottom.BOTTOM_BAR_HEIGHT / 2;
|
|
|
|
this.leftText = this.printBottomText(this.leftText, "", "left");
|
|
this.centerText = this.printBottomText(this.centerText, "", "center");
|
|
this.rightText = this.printBottomText(this.rightText, "", "right");
|
|
}
|
|
|
|
makeBottomLine() {
|
|
game.add.graphics()
|
|
.beginFill(0xffffff, 0.1)
|
|
.drawRect(
|
|
0, game.world.height - ScreenBottom.BOTTOM_BAR_HEIGHT,
|
|
game.world.width, ScreenBottom.BOTTOM_BAR_HEIGHT
|
|
);
|
|
}
|
|
|
|
printBottomLeftText(text) {
|
|
this.leftText.text = text;
|
|
}
|
|
|
|
printBottomCenterText(text) {
|
|
this.centerText.text = text;
|
|
}
|
|
|
|
printBottomRightText(text) {
|
|
this.rightText.text = text;
|
|
}
|
|
|
|
printBottomText(textObject, text, align) {
|
|
if(textObject !== null && textObject !== undefined) {
|
|
textObject.text = "";
|
|
textObject = null;
|
|
}
|
|
|
|
let posX = 0;
|
|
let anchorValue = 0;
|
|
switch(align) {
|
|
case "left":
|
|
posX = ScreenBottom.BOTTOM_BAR_TEXT_OFFSET;
|
|
break;
|
|
|
|
case "center":
|
|
posX = game.world.centerX;
|
|
anchorValue = 0.5;
|
|
break;
|
|
|
|
case "right":
|
|
posX = game.world.width - ScreenBottom.BOTTOM_BAR_TEXT_OFFSET;
|
|
anchorValue = 1;
|
|
break;
|
|
}
|
|
|
|
textObject = game.add.text(posX, this.bottomBarCenterY, text, this.getFontStyle());
|
|
|
|
textObject.anchor.x = anchorValue;
|
|
textObject.anchor.y = 0.5;
|
|
|
|
return textObject;
|
|
}
|
|
|
|
printBottomLeftTextWithBestRecord(bestRecord) {
|
|
let roundUpBestRecord = Math.round(bestRecord);
|
|
let highScoreWithCommas = NumberUtil.numberWithCommas(roundUpBestRecord);
|
|
this.printBottomLeftText("오늘의 최고 기록 : " + highScoreWithCommas);
|
|
}
|
|
|
|
getFontStyle() {
|
|
return { font: "32px Arial", fill: "#fff", align: "left", boundsAlignH: "left", boundsAlignV: "bottom" };
|
|
}
|
|
|
|
}
|
|
|
|
ScreenBottom.BOTTOM_BAR_HEIGHT = 50;
|
|
ScreenBottom.BOTTOM_BAR_NAME_WIDTH = 200;
|
|
ScreenBottom.BOTTOM_BAR_TEXT_OFFSET = 10; |