Add: move hands with keys

This commit is contained in:
2018-06-20 09:12:08 +09:00
parent 6a5a2db670
commit ba3b88793b
3 changed files with 132 additions and 80 deletions
+38 -25
View File
@@ -52,6 +52,7 @@ class TypingPractice {
.addColor(textPreviewColor[0], 0);
// keyboard
this.keyMapper = new KeyMapper();
this.keyboard = null;
if(sessionStorageManager.playingAppName.indexOf("korean") > 0)
@@ -64,27 +65,12 @@ class TypingPractice {
}
this.shiftKey = game.input.keyboard.addKey(Phaser.Keyboard.SHIFT);
/*
this.hand_left = game.add.image(370, 680, "hand_left");
this.hand_left.scale.set(2);
this.hand_left.anchor.set(0.5);
this.hand_right = game.add.image(630, 680, "hand_right");
this.hand_right.scale.set(2);
this.hand_right.anchor.set(0.5);
let mask = game.add.graphics();
mask.beginFill(0xffffff);
mask.drawRect(100, 300, 1028, 400);
this.hand_left.mask = mask;
this.hand_right.mask = mask;
*/
// hands
this.leftHand = new LeftHand(this.keyMapper);
this.rightHand = new RightHand(this.keyMapper);
// bottom
let screenBottom = new ScreenBottom();
screenBottom.makeBottomLine();
@@ -99,7 +85,8 @@ class TypingPractice {
startGame() {
this.showTypingPracticeContents();
this.showHighlightKey()
this.showHighlightKey();
this.moveHands();
this.showPlayingWordNumber();
}
@@ -113,6 +100,9 @@ class TypingPractice {
this.textTypingContent.clearColors();
this.textTypingContent.addColor(TypingPractice.COLOR_CONTENT_RIGHT, 0);
this.textTypingContent.text = "= 연습 끝 =";
this.leftHand.moveToDefaultPosition();
this.rightHand.moveToDefaultPosition();
/*
sessionStorageManager.record = this.typingRecordTotal;
if(sessionStorageManager.record > sessionStorageManager.bestRecord)
@@ -249,15 +239,37 @@ class TypingPractice {
return;
this.keyboard.showHighlight(typingText, this.leftHand, this.rightHand);
// let key = this.keyboard.getKeyOfText(typingText);
// if(key.handSide == KeyButton.LEFT_HAND) {
// this.leftHand.moveRow(key.row);
// } else if(key.handSide == KeyButton.LEFT_HAND) {
// this.rightHand.moveRow(key.row);
// }
}
moveHands() {
let typingText = this.typingRandomContents[this.typingIndex];
if(typingText === undefined)
return;
let key = this.keyboard.getKeyOfText(typingText);
let handSide = key.handSide;
if(handSide === KeyButton.LEFT_HAND) {
this.leftHand.moveTo(key);
if(this.keyMapper.isShiftText(typingText)) {
let shiftRightKey = this.keyboard.getKey("ShiftRight");
shiftRightKey.showHighlight();
this.rightHand.moveTo(shiftRightKey);
} else {
this.rightHand.moveToDefaultPosition();
}
} else {
this.rightHand.moveTo(key);
if(this.keyMapper.isShiftText(typingText)) {
let shiftLeftKey = this.keyboard.getKey("ShiftLeft");
shiftLeftKey.showHighlight();
this.leftHand.moveTo(shiftLeftKey);
} else {
this.leftHand.moveToDefaultPosition();
}
}
}
getKeyCode(text) {
return this.keyMapper.getKeyIDOfText(text);
@@ -301,6 +313,7 @@ class TypingPractice {
this.typingIndex++;
this.showTypingPracticeContents();
this.showHighlightKey();
this.moveHands();
this.showPlayingWordNumber();
}