Add: StageTimer
This commit is contained in:
@@ -33,6 +33,10 @@ function StageTimer(stageTimerSec, onTimeOver) {
|
||||
this.bonusTimeText.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
|
||||
};
|
||||
|
||||
StageTimer.prototype.setDisplayType = function(type) {
|
||||
this.displayType = type;
|
||||
}
|
||||
|
||||
StageTimer.prototype.start = function() {
|
||||
this.timeLeft = this.stageTimerSec;
|
||||
this.printTime();
|
||||
@@ -68,7 +72,40 @@ StageTimer.prototype.updateTimer = function() {
|
||||
}
|
||||
|
||||
StageTimer.prototype.printTime = function() {
|
||||
this.timerText.text = this.timeLeft.toString() + "초";
|
||||
if(this.displayType == StageTimer.DISPLAY_TYPE_SEC) {
|
||||
this.timerText.text = this.timeLeft.toString() + "초";
|
||||
return;
|
||||
}
|
||||
|
||||
var hours = Math.floor(this.timeLeft / 60 / 60);
|
||||
var minutes = Math.floor(this.timeLeft / 60);
|
||||
var seconds = this.timeLeft % 60;
|
||||
|
||||
// console.log("hours : " + hours);
|
||||
// console.log("minutes : " + minutes);
|
||||
// console.log("seconds : " + seconds);
|
||||
|
||||
this.timerText.text = "";
|
||||
var timeText = "";
|
||||
|
||||
if(hours > 0)
|
||||
timeText = hours + "시간";
|
||||
|
||||
if(minutes > 0) {
|
||||
if(timeText != "")
|
||||
timeText += " ";
|
||||
|
||||
timeText = minutes + "분";
|
||||
}
|
||||
|
||||
if(seconds > 0) {
|
||||
if(timeText != "")
|
||||
timeText += " ";
|
||||
|
||||
timeText += seconds + "초";
|
||||
}
|
||||
|
||||
this.timerText.text = timeText;
|
||||
}
|
||||
|
||||
StageTimer.prototype.removeTimer = function() {
|
||||
@@ -94,6 +131,9 @@ StageTimer.prototype.addBonusTime = function(timeSec) {
|
||||
}
|
||||
|
||||
|
||||
StageTimer.DISPLAY_TYPE_NON_SEC = 0;
|
||||
StageTimer.DISPLAY_TYPE_SEC = 1;
|
||||
|
||||
StageTimer.FONT_HEIGHT_PX = 70;
|
||||
|
||||
StageTimer.DEFAULT_TEXT_FONT = {
|
||||
|
||||
@@ -52,6 +52,16 @@ var TypingExamination = {
|
||||
this.averageTypingSpeedText = new AverageTypingSpeed();
|
||||
// this.contentProgressText = new ContentProgress();
|
||||
|
||||
this.stageTimer = new StageTimer(
|
||||
TypingExamination.GAME_TIME_SEC,
|
||||
(function() {
|
||||
this.setClickEnable(false);
|
||||
this.timeOver();
|
||||
}).bind(this)
|
||||
);
|
||||
this.stageTimer.setDisplayType(StageTimer.DISPLAY_TYPE_NON_SEC);
|
||||
|
||||
|
||||
|
||||
// typing content
|
||||
var typingContentBG = new TypingContentBG();
|
||||
@@ -66,7 +76,11 @@ var TypingExamination = {
|
||||
var TYPING_CONTENT_Y = 340;
|
||||
var RECORD_POSITION_X = 900;
|
||||
|
||||
textStyleBasic.font = "bold 38px Arial";
|
||||
var FONT_SIZE = 24;
|
||||
var BIG_FONT_SIZE = 32;
|
||||
var TYPING_TEXT_OFFSET_HEIGHT = 40;
|
||||
|
||||
// textStyleBasic.font = "bold 38px Arial";
|
||||
// textStyleBasic.backgroundColor = "rgba(0, 0, 0, 0.25)";
|
||||
|
||||
|
||||
@@ -78,6 +92,7 @@ var TypingExamination = {
|
||||
.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2)
|
||||
.addColor(TypingExamination.COLOR_CONTENT_INPUT, 0);
|
||||
this.textTypingContent.anchor.set(0, 0.5);
|
||||
this.textTypingContent.fontSize = BIG_FONT_SIZE;
|
||||
|
||||
textStyleBasic.backgroundColor = null;
|
||||
this.textTypingLine = game.add.text(
|
||||
@@ -92,13 +107,13 @@ var TypingExamination = {
|
||||
|
||||
var TYPING_OFFSET_Y = 70;
|
||||
var TYPING_PREVIEW_OFFSET_Y = 70;
|
||||
var TYPING_TEXT_OFFSET_HEIGHT = 50;
|
||||
textStyleBasic.font = "38px Arial";
|
||||
textStyleBasic.backgroundColor = null;
|
||||
|
||||
|
||||
// done text
|
||||
var textDoneColor = [ '#99994d', '#77774d', '#66664d' ];
|
||||
// var textDoneColor = [ '#99994d', '#88884d', '#77774d', '#66664d' ];
|
||||
var textDoneColor = [ '#dddd4d', '#dddd4d', '#dddd4d', '#dddd4d' ];
|
||||
this.textTypingContentsDone = [];
|
||||
this.textTypingRecordsDone = [];
|
||||
for(var i = 0; i < TypingExamination.TYPING_CONTENT_DONE_COUNT; i++) {
|
||||
@@ -106,21 +121,24 @@ var TypingExamination = {
|
||||
TYPING_CONTENT_X, TYPING_CONTENT_Y - TYPING_OFFSET_Y - i * TYPING_TEXT_OFFSET_HEIGHT,
|
||||
"", textStyleBasic
|
||||
)
|
||||
// .setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2)
|
||||
.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2)
|
||||
.addColor(textDoneColor[i], 0);
|
||||
this.textTypingContentsDone[i].anchor.set(0, 0.5);
|
||||
this.textTypingContentsDone[i].fontSize = FONT_SIZE;
|
||||
|
||||
this.textTypingRecordsDone[i] = game.add.text(
|
||||
RECORD_POSITION_X, TYPING_CONTENT_Y - TYPING_OFFSET_Y - i * TYPING_TEXT_OFFSET_HEIGHT,
|
||||
"", textStyleBasic
|
||||
)
|
||||
// .setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2)
|
||||
.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2)
|
||||
.addColor(textDoneColor[i], 0);
|
||||
this.textTypingRecordsDone[i].anchor.set(0.5);
|
||||
this.textTypingRecordsDone[i].fontSize = FONT_SIZE;
|
||||
}
|
||||
|
||||
// preview text
|
||||
var textPreviewColor = [ '#999999', '#888888', '#777777' ];
|
||||
// var textPreviewColor = [ '#999999', '#888888', '#777777', '#666666' ];
|
||||
var textPreviewColor = [ '#dddddd', '#dddddd', '#dddddd', '#dddddd' ];
|
||||
this.textTypingContentPreview = [];
|
||||
for(var i = 0; i < TypingExamination.TYPING_CONTENT_PREVIEW_COUNT; i++) {
|
||||
this.textTypingContentPreview[i] = game.add.text(
|
||||
@@ -128,18 +146,19 @@ var TypingExamination = {
|
||||
TYPING_CONTENT_Y + TYPING_OFFSET_Y + TYPING_PREVIEW_OFFSET_Y + i * TYPING_TEXT_OFFSET_HEIGHT,
|
||||
"", textStyleBasic
|
||||
)
|
||||
// .setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2)
|
||||
.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2)
|
||||
.addColor(textPreviewColor[i], 0);
|
||||
this.textTypingContentPreview[i].anchor.set(0, 0.5);
|
||||
this.textTypingContentPreview[i].fontSize = FONT_SIZE;
|
||||
}
|
||||
|
||||
|
||||
// input text
|
||||
this.inputTextContent = new InputTypeText(TYPING_CONTENT_X, TYPING_CONTENT_Y + 70);
|
||||
this.inputTextContent = new InputTypeText(TYPING_CONTENT_X - 10, TYPING_CONTENT_Y + 70);
|
||||
this.inputTextContent.anchor.set(0, 0.5);
|
||||
this.inputTextContent.canvasInput.value('');
|
||||
this.inputTextContent.canvasInput.focus();
|
||||
this.inputTextContent.canvasInput.fontSize(38);
|
||||
this.inputTextContent.canvasInput.fontSize(BIG_FONT_SIZE);
|
||||
this.inputTextContent.canvasInput.placeHolder("");
|
||||
// inputTextContent.canvasInput._onkeydown = this.checkInputText;
|
||||
// inputTextContent.canvasInput._onkeyup = function() {
|
||||
@@ -226,11 +245,13 @@ var TypingExamination = {
|
||||
this.showTypingExaminationContents();
|
||||
this.showPlayingWordNumber();
|
||||
// this.updateKeyboard();
|
||||
|
||||
this.stageTimer.start();
|
||||
},
|
||||
|
||||
timeOver: function() {
|
||||
var timeOverText = new TimeOverText();
|
||||
this.stopAndGoResult();
|
||||
// this.stopAndGoResult();
|
||||
},
|
||||
|
||||
gameOver: function() {
|
||||
@@ -826,10 +847,12 @@ var TypingExamination = {
|
||||
}
|
||||
|
||||
|
||||
TypingExamination.GAME_TIME_SEC = 60 * 5; // 5 minutes
|
||||
|
||||
TypingExamination.SPACE_INDICATOR = " · ";
|
||||
|
||||
TypingExamination.TYPING_CONTENT_PREVIEW_COUNT = 3; // 3;
|
||||
TypingExamination.TYPING_CONTENT_DONE_COUNT = 3; // 3;
|
||||
TypingExamination.TYPING_CONTENT_PREVIEW_COUNT = 4; // 3;
|
||||
TypingExamination.TYPING_CONTENT_DONE_COUNT = 4; // 3;
|
||||
TypingExamination.TYPING_COUNT_PLUS_ENTER = 1;
|
||||
|
||||
TypingExamination.OFFSET_RIGHT_ALIGN = 10;
|
||||
|
||||
@@ -181,4 +181,4 @@ TypingTextManager.ENGLISH_LETTER_RIGHT = [
|
||||
];
|
||||
|
||||
|
||||
TypingTextManager.SENTENCE_MAX_CHARACTER = 27;
|
||||
TypingTextManager.SENTENCE_MAX_CHARACTER = 35; // 27;
|
||||
@@ -58,27 +58,7 @@
|
||||
<script src="../../game/lib/button/fullscreen_button.js"></script>
|
||||
<script src="../../game/lib/db_connect_manager.js"></script>
|
||||
<script src="../../game/lib/experience_app_timer.js"></script>
|
||||
|
||||
<!-- Examination typing : source files -->
|
||||
<script src="../../game/typing/word_list/korean_basic.js"></script>
|
||||
<script src="../../game/typing/word_list/korean_left_upper.js"></script>
|
||||
<script src="../../game/typing/word_list/korean_second_finger.js"></script>
|
||||
<script src="../../game/typing/word_list/korean_right_upper.js"></script>
|
||||
<script src="../../game/typing/word_list/korean_left_lower.js"></script>
|
||||
<script src="../../game/typing/word_list/korean_right_lower.js"></script>
|
||||
<script src="../../game/typing/word_list/korean_left_upper_double.js"></script>
|
||||
<script src="../../game/typing/word_list/korean_right_upper_double.js"></script>
|
||||
<script src="../../game/typing/word_list/korean_word.js"></script>
|
||||
<script src="../../game/typing/word_list/korean_sentence.js"></script>
|
||||
|
||||
<script src="../../game/typing/word_list/english_basic.js"></script>
|
||||
<script src="../../game/typing/word_list/english_left_lower.js"></script>
|
||||
<script src="../../game/typing/word_list/english_left_upper.js"></script>
|
||||
<script src="../../game/typing/word_list/english_right_lower.js"></script>
|
||||
<script src="../../game/typing/word_list/english_right_upper.js"></script>
|
||||
<script src="../../game/typing/word_list/english_second_finger.js"></script>
|
||||
<script src="../../game/typing/word_list/english_sentence.js"></script>
|
||||
<script src="../../game/typing/word_list/english_word.js"></script>
|
||||
<script src="../../game/lib/stage_timer.js"></script>
|
||||
|
||||
<!-- Examination typing : source files -->
|
||||
<script src="../../game/typing/lib/content_progress.js"></script>
|
||||
|
||||
Reference in New Issue
Block a user