Fix: remove aftereffect of ScreenBottom text

This commit is contained in:
2018-08-09 16:19:14 +09:00
parent 802736b5f9
commit 9e0dcb6860
3 changed files with 91 additions and 45 deletions
+49 -38
View File
@@ -4,51 +4,22 @@
class ScreenBottom {
constructor() {
this.BOTTOM_BAR_HEIGHT = 50;
this.BOTTOM_BAR_NAME_WIDTH = 200;
this.BOTTOM_BAR_TEXT_OFFSET = 10;
this.dbConnectManager = new DBConnectManager();
this.bottomAreaPositionY = game.world.height - this.BOTTOM_BAR_HEIGHT;
this.bottomBarCenterY = game.world.height - ScreenBottom.BOTTOM_BAR_HEIGHT / 2;
let style = { font: "32px Arial", fill: "#fff", align: "left", boundsAlignH: "left", boundsAlignV: "bottom" };
let posX = this.BOTTOM_BAR_TEXT_OFFSET;
this.leftText = game.add.text(posX, this.bottomAreaPositionY, "", style)
.setTextBounds(0, 0, this.BOTTOM_BAR_NAME_WIDTH, this.BOTTOM_BAR_HEIGHT)
.addColor('#ffffff', 0);
// .setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
// let style = { font: "32px Arial", fill: "#fff", align: "center", boundsAlignH: "center", boundsAlignV: "bottom" };
style.align = "center";
style.boundsAlignH = "center";
posX = game.world.width / 2 - this.BOTTOM_BAR_NAME_OFFSET_RIGHT;
this.centerText = game.add.text(0, this.bottomAreaPositionY, "", style)
.setTextBounds(0, 0, game.world.width, this.BOTTOM_BAR_HEIGHT)
.addColor('#ffffff', 0);
// .setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
// let style = { font: "32px Arial", fill: "#fff", align: "right", boundsAlignH: "right", boundsAlignV: "bottom" };
style.align = "right";
style.boundsAlignH = "right";
posX = game.world.width - this.BOTTOM_BAR_NAME_WIDTH - this.BOTTOM_BAR_TEXT_OFFSET;
this.rightText = game.add.text(posX, this.bottomAreaPositionY, "", style)
.setTextBounds(0, 0, this.BOTTOM_BAR_NAME_WIDTH, this.BOTTOM_BAR_HEIGHT)
.addColor('#ffffff', 0);
// .setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
this.leftText = this.printBottomText(this.leftText, "sample", "left");
this.centerText = this.printBottomText(this.centerText, "sample", "center");
this.rightText = this.printBottomText(this.rightText, "sample", "right");
}
makeBottomLine() {
game.add.graphics()
.beginFill(0xffffff, 0.1)
.drawRect(0, this.bottomAreaPositionY, game.world.width, this.BOTTOM_BAR_HEIGHT);
let textStyleInfo = textStyleBasic; //$.extend( {}, textStyleBasic);
textStyleInfo.font = "32px Arial";
textStyleInfo.align = "right";
textStyleInfo.boundsAlignH = "right";
.drawRect(
0, game.world.height - ScreenBottom.BOTTOM_BAR_HEIGHT,
game.world.width, ScreenBottom.BOTTOM_BAR_HEIGHT
);
}
printBottomLeftText(text) {
@@ -63,10 +34,50 @@ class ScreenBottom {
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;