Add: input_score

This commit is contained in:
2018-12-10 08:21:43 +09:00
parent 13f59aee71
commit 364362618b
5 changed files with 228 additions and 200 deletions
+3 -133
View File
@@ -1,10 +1,6 @@
var LicenseTimer = {
create: function() {
Phaser.Device.whenReady(function () {
game.plugins.add(PhaserInput.Plugin);
  });
game.stage.backgroundColor = "#4d4d4d";
this.initVariables();
@@ -30,109 +26,14 @@ var LicenseTimer = {
// this.fullscreenButton = new FullscreenButton();
this.timer = new Timer();
this.chart = new Chart();
this.chart.printContents();
this.makeInputScoreGroup();
this.inputScore = new InputScore(this.chart);
},
initVariables: function() {
this.subject = "ITQ 파워포인트";
this.recentRecord = 500;
this.prevTime = null;
this.timeLeft = 0;
this.timeLeftHour = 0;
this.timeLeftMinute = 0;
this.timeLeftSecond = 0;
this.timerEvent = null;
},
makeTimer: function() {
},
makeInputScoreGroup: function() {
var InputScoreGruopPosY = GAME_SCREEN_SIZE.y - LicenseTimer.INPUT_SCORE_GROUP_OFFSET_Y;
// bar
var bar = game.add.graphics();
bar.beginFill(0x303030); //, 0.2);
bar.drawRect(0, InputScoreGruopPosY, GAME_SCREEN_SIZE.x, 70);
var subjectTextSetting = this.makeInputTextSetting(300, "과목 입력");
this.subjectText = this.makeInputText(20, InputScoreGruopPosY + 10, subjectTextSetting);
this.subjectText.setText(this.subject);
var setting = new RoundRectButtonSetting(0, 0, 0, 0);
setting.fontStyle.boundsAlignH = "left"; // left, center. right
setting.fontStyle.boundsAlignV = "middle"; // top, middle, bottom
setting.strokeWidthPx = 5;
var titleTextStyle = { font: "36px Arial", fill: "#fff", align: "center"};
this.titleText = game.add.text(350, InputScoreGruopPosY + 40, "과목", titleTextStyle);
this.titleText.anchor.set(0, 0.5);
// subject input text
// var inputTextSetting = this.makeInputTextSetting(200, "점수 입력");
var recordTextSetting = this.makeInputTextSetting(150, "점수 입력");
this.recordText = this.makeInputText(game.world.centerX - 50, InputScoreGruopPosY + 10, recordTextSetting);
// this.subjectText.setText(this.subject);
this.titleText = game.add.text(640, InputScoreGruopPosY + 40, "점", titleTextStyle);
this.titleText.anchor.set(0, 0.5);
var passwordTextSetting = this.makeInputTextSetting(150, "비밀번호");
passwordTextSetting.type = PhaserInput.InputType.password;
this.passwordText = this.makeInputText(GAME_SCREEN_SIZE.x - 330, InputScoreGruopPosY + 10, passwordTextSetting);
// set timer buttons
setting.x = GAME_SCREEN_SIZE.x - 80;
setting.y = InputScoreGruopPosY + 35;
setting.width = 100;
setting.height = 50;
var set60SecButton = new RoundRectButton(
setting,
null, "저장",
(function() { console.log(this.subjectText.value); console.log("save score"); }).bind(this)
);
},
setInputTextWidth(inputText, width) {
inputText.canvasInput.width = width;
inputText.canvasInput._shadowCanvas.setAttribute('width', self._width + self._padding * 2);
inputText.canvasInput._hiddenInput.style.width = self._width + 'px';
inputText.canvasInput._width = width;
inputText.canvasInput._calcWH();
inputText.canvasInput._updateCanvasWH();
inputText.canvasInput.render();
},
makeInputTypeText: function(x, y, text) {
var inputText = new InputTypeText(x, y);
inputText.anchor.set(0.5);
inputText.canvasInput.value('');
if(isDebugMode()) {
inputText.canvasInput.value(text);
}
inputText.canvasInput._onkeyup = (function() {
if(event.keyCode == Phaser.Keyboard.ENTER) {
this.startMenu();
}
}).bind(this);
return inputText;
},
@@ -142,35 +43,4 @@ var LicenseTimer = {
game.state.start('Login');
},
makeInputTextSetting(width, placeHolder) {
return {
font: "32px Arial",
fill: "#000000",
fillAlpha: 1,
fontWeight: "bold",
forceCase: "", // PhaserInput.ForceCase.upper,
width: width,
max: 100,
padding: 8,
borderWidth: 1,
borderColor: "#aaa",
borderRadius: 6,
placeHolder: placeHolder,
textAlign: "center",
zoom: true
}
},
makeInputText(x, y, setting) {
var inputText = game.add.inputField(x, y, setting);
inputText.setText('');
inputText.blockInput = false;
return inputText;
},
}
LicenseTimer.INPUT_SCORE_GROUP_OFFSET_Y = 70;
}