Fix: restructing session manager, ES6 -> ES5
This commit is contained in:
@@ -1,20 +1,16 @@
|
||||
/////////////////////////////
|
||||
// TypingPractice
|
||||
|
||||
class TypingPractice {
|
||||
|
||||
create() {
|
||||
self = this;
|
||||
var TypingPractice = {
|
||||
create: function() {
|
||||
var self = this;
|
||||
|
||||
this.isOnStage = false;
|
||||
|
||||
this.initTypingData();
|
||||
sessionStorageManager.isNewBestRecrd = false;
|
||||
sessionStorageManager.setIsNewBestRecord(false);
|
||||
|
||||
game.stage.backgroundColor = '#4d4d4d';
|
||||
|
||||
// top ui
|
||||
let screenTopUI = new ScreenTopUI();
|
||||
var screenTopUI = new ScreenTopUI();
|
||||
screenTopUI.makeBackButton( function() {
|
||||
sessionStorageManager.resetPlayingAppData();
|
||||
location.href = '../../web/client/menu_typing_practice.html';
|
||||
@@ -38,10 +34,10 @@ class TypingPractice {
|
||||
|
||||
|
||||
// typing content
|
||||
let typingContentBG = new TypingContentBG();
|
||||
var typingContentBG = new TypingContentBG();
|
||||
typingContentBG.makePracticeContentBG();
|
||||
|
||||
let TYPING_CONTENT_Y = 200;
|
||||
var TYPING_CONTENT_Y = 200;
|
||||
|
||||
textStyleBasic.font = "bold 84px Times New Roman";
|
||||
this.textTypingContent = game.add.text(game.world.centerX, TYPING_CONTENT_Y, "", textStyleBasic)
|
||||
@@ -56,11 +52,11 @@ class TypingPractice {
|
||||
|
||||
|
||||
// textStyleBasic.font = "32px Arial";
|
||||
let OFFSET_WORD_X = 70;
|
||||
var OFFSET_WORD_X = 70;
|
||||
|
||||
let textDoneColor = [ '#99994d', '#77774d', '#66664d' ];
|
||||
var textDoneColor = [ '#99994d', '#77774d', '#66664d' ];
|
||||
this.textTypingContentsDone = [];
|
||||
for(let i = 0; i < TypingPractice.TYPING_CONTENT_DONE_COUNT; i++) {
|
||||
for(var i = 0; i < TypingPractice.TYPING_CONTENT_DONE_COUNT; i++) {
|
||||
this.textTypingContentsDone[i] = game.add.text(
|
||||
game.world.centerX - 200 - i * OFFSET_WORD_X, TYPING_CONTENT_Y,
|
||||
"", textStyleBasic
|
||||
@@ -69,9 +65,9 @@ class TypingPractice {
|
||||
this.textTypingContentsDone[i].anchor.set(0.5);
|
||||
}
|
||||
|
||||
let textPreviewColor = [ '#666666', '#888888', '#777777' ];
|
||||
var textPreviewColor = [ '#666666', '#888888', '#777777' ];
|
||||
this.textTypingContentPreview = [];
|
||||
for(let i = 0; i < TypingPractice.TYPING_CONTENT_PREVIEW_COUNT; i++) {
|
||||
for(var i = 0; i < TypingPractice.TYPING_CONTENT_PREVIEW_COUNT; i++) {
|
||||
this.textTypingContentPreview[i] = game.add.text(
|
||||
game.world.centerX + 200 + i * OFFSET_WORD_X,
|
||||
TYPING_CONTENT_Y, "", textStyleBasic
|
||||
@@ -83,7 +79,7 @@ class TypingPractice {
|
||||
// keyboard
|
||||
this.keyMapper = new KeyMapper();
|
||||
this.keyboard = null;
|
||||
if(sessionStorageManager.playingAppName.indexOf("korean") > 0)
|
||||
if(sessionStorageManager.getPlayingAppName().indexOf("korean") > 0)
|
||||
this.keyboard = new Keyboard(this.keyMapper, Keyboard.KOREAN);
|
||||
else
|
||||
this.keyboard = new Keyboard(this.keyMapper, Keyboard.ENGLISH);
|
||||
@@ -103,29 +99,29 @@ class TypingPractice {
|
||||
|
||||
|
||||
// bottom ui
|
||||
let screenBottomUI = new ScreenBottomUI();
|
||||
var screenBottomUI = new ScreenBottomUI();
|
||||
// screenBottomUI.printBottomUILeftText("");
|
||||
screenBottomUI.printCenterText(sessionStorageManager.playingAppKoreanName);
|
||||
screenBottomUI.printRightText(sessionStorageManager.playerName);
|
||||
screenBottomUI.printCenterText(sessionStorageManager.getPlayingAppKoreanName());
|
||||
screenBottomUI.printRightText(sessionStorageManager.getPlayerName());
|
||||
|
||||
|
||||
this.startGame();
|
||||
// this.countDown();
|
||||
}
|
||||
},
|
||||
|
||||
startGame() {
|
||||
startGame: function() {
|
||||
this.isOnStage = true;
|
||||
this.stageTimer.start();
|
||||
|
||||
this.showTypingPracticeContents();
|
||||
this.showHighlightKey();
|
||||
this.moveHands();
|
||||
}
|
||||
},
|
||||
|
||||
gameOver() {
|
||||
gameOver: function() {
|
||||
this.isOnStage = false;
|
||||
|
||||
for(let i = 0; i < TypingPractice.TYPING_CONTENT_DONE_COUNT; i++) {
|
||||
for(var i = 0; i < TypingPractice.TYPING_CONTENT_DONE_COUNT; i++) {
|
||||
this.textTypingContentsDone[i].text = "";
|
||||
}
|
||||
|
||||
@@ -135,7 +131,7 @@ class TypingPractice {
|
||||
this.textTypingContent.addColor(TypingPractice.COLOR_CONTENT_RIGHT, 0);
|
||||
this.textTypingContent.text = "= 연습 끝 =";
|
||||
|
||||
for(let i = 0; i < TypingPractice.TYPING_CONTENT_PREVIEW_COUNT; i++) {
|
||||
for(var i = 0; i < TypingPractice.TYPING_CONTENT_PREVIEW_COUNT; i++) {
|
||||
this.textTypingContentPreview[i].text = "";
|
||||
}
|
||||
|
||||
@@ -144,22 +140,22 @@ class TypingPractice {
|
||||
|
||||
this.animalOnTitle.stopAnimation();
|
||||
|
||||
let gameOverText = new GameOverText();
|
||||
var gameOverText = new GameOverText();
|
||||
game.time.events.add(Phaser.Timer.SECOND * 2, this.goResult, this);
|
||||
}
|
||||
},
|
||||
|
||||
goResult() {
|
||||
sessionStorageManager.record = this.typingScore.score();
|
||||
if(sessionStorageManager.record > sessionStorageManager.bestRecord)
|
||||
sessionStorageManager.bestRecord = sessionStorageManager.record;
|
||||
goResult: function() {
|
||||
sessionStorageManager.setRecord(this.typingScore.score());
|
||||
if(sessionStorageManager.getRecord() > sessionStorageManager.getBestRecord())
|
||||
sessionStorageManager.setBestRecord(sessionStorageManager.getRecord());
|
||||
|
||||
location.href = '../../web/client/result.html';
|
||||
}
|
||||
},
|
||||
|
||||
initTypingData() {
|
||||
let typingTextMan = new TypingTextManager();
|
||||
initTypingData: function() {
|
||||
var typingTextMan = new TypingTextManager();
|
||||
|
||||
let typingPracticeContents = this.loadPracticeContent();
|
||||
var typingPracticeContents = this.loadPracticeContent();
|
||||
// console.log(typingPracticeContents);
|
||||
typingTextMan.makePracticeContents(typingPracticeContents, 30);
|
||||
this.typingRandomContents = typingTextMan.getContents();
|
||||
@@ -168,17 +164,17 @@ class TypingPractice {
|
||||
this.typingIndex = 0;
|
||||
|
||||
this.playingAnimalIndex = 0;
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
loadPracticeContent() {
|
||||
let appName = "";
|
||||
loadPracticeContent: function() {
|
||||
var appName = "";
|
||||
if(isTypingTestStage())
|
||||
appName = sessionStorageManager.playingAppName.substring(5);
|
||||
appName = sessionStorageManager.getPlayingAppName().substring(5);
|
||||
else if(isTypingPracticeStage())
|
||||
appName = sessionStorageManager.playingAppName.substring(9);
|
||||
appName = sessionStorageManager.getPlayingAppName().substring(9);
|
||||
|
||||
let testContent = [];
|
||||
var testContent = [];
|
||||
|
||||
switch(appName) {
|
||||
case "korean_basic":
|
||||
@@ -260,11 +256,11 @@ class TypingPractice {
|
||||
}
|
||||
|
||||
return testContent;
|
||||
}
|
||||
},
|
||||
|
||||
showTypingPracticeContents() {
|
||||
for(let i = 0; i < TypingPractice.TYPING_CONTENT_DONE_COUNT; i++) {
|
||||
let doneIndex = this.typingIndex - i - 1;
|
||||
showTypingPracticeContents: function() {
|
||||
for(var i = 0; i < TypingPractice.TYPING_CONTENT_DONE_COUNT; i++) {
|
||||
var doneIndex = this.typingIndex - i - 1;
|
||||
if(doneIndex < 0) {
|
||||
this.textTypingContentsDone[i].text = "";
|
||||
} else {
|
||||
@@ -279,43 +275,43 @@ class TypingPractice {
|
||||
|
||||
this.textTypingContent.text = this.typingRandomContents[this.typingIndex];
|
||||
|
||||
for(let i = 0; i < TypingPractice.TYPING_CONTENT_PREVIEW_COUNT; i++) {
|
||||
let previewIndex = this.typingIndex + i + 1;
|
||||
for(var i = 0; i < TypingPractice.TYPING_CONTENT_PREVIEW_COUNT; i++) {
|
||||
var previewIndex = this.typingIndex + i + 1;
|
||||
if(previewIndex < this.typingRandomContents.length)
|
||||
this.textTypingContentPreview[i].text = this.typingRandomContents[previewIndex];
|
||||
else
|
||||
this.textTypingContentPreview[i].text = "";
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
hideHighlightKey() {
|
||||
let prevText = this.typingRandomContents[this.typingIndex];
|
||||
hideHighlightKey: function() {
|
||||
var prevText = this.typingRandomContents[this.typingIndex];
|
||||
if(prevText === undefined)
|
||||
return;
|
||||
|
||||
this.keyboard.hideHighlight(prevText);
|
||||
}
|
||||
},
|
||||
|
||||
showHighlightKey() {
|
||||
let typingText = this.typingRandomContents[this.typingIndex];
|
||||
showHighlightKey: function() {
|
||||
var typingText = this.typingRandomContents[this.typingIndex];
|
||||
if(typingText === undefined)
|
||||
return;
|
||||
|
||||
this.keyboard.showHighlight(typingText, this.leftHand, this.rightHand);
|
||||
}
|
||||
},
|
||||
|
||||
moveHands() {
|
||||
let typingText = this.typingRandomContents[this.typingIndex];
|
||||
moveHands: function() {
|
||||
var typingText = this.typingRandomContents[this.typingIndex];
|
||||
if(typingText === undefined)
|
||||
return;
|
||||
|
||||
let key = this.keyboard.getKeyOfText(typingText);
|
||||
let handSide = key.handSide;
|
||||
var key = this.keyboard.getKeyOfText(typingText);
|
||||
var handSide = key.handSide;
|
||||
if(handSide === KeyButton.LEFT_HAND) {
|
||||
this.leftHand.moveTo(key);
|
||||
|
||||
if(this.keyMapper.isShiftText(typingText)) {
|
||||
let shiftRightKey = this.keyboard.getKey("ShiftRight");
|
||||
var shiftRightKey = this.keyboard.getKey("ShiftRight");
|
||||
shiftRightKey.showHighlight();
|
||||
this.rightHand.moveTo(shiftRightKey);
|
||||
} else {
|
||||
@@ -325,42 +321,42 @@ class TypingPractice {
|
||||
this.rightHand.moveTo(key);
|
||||
|
||||
if(this.keyMapper.isShiftText(typingText)) {
|
||||
let shiftLeftKey = this.keyboard.getKey("ShiftLeft");
|
||||
var shiftLeftKey = this.keyboard.getKey("ShiftLeft");
|
||||
shiftLeftKey.showHighlight();
|
||||
this.leftHand.moveTo(shiftLeftKey);
|
||||
} else {
|
||||
this.leftHand.moveToDefaultPosition();
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
getKeyCode(text) {
|
||||
getKeyCode: function(text) {
|
||||
return this.keyMapper.getKeyIDOfText(text);
|
||||
}
|
||||
},
|
||||
|
||||
isKeyPressed(inputContent, typingContent) {
|
||||
let inputContentKeyCode = this.getKeyCode(inputContent);
|
||||
let typingContentKeyCode = this.getKeyCode(typingContent);
|
||||
isKeyPressed: function(inputContent, typingContent) {
|
||||
var inputContentKeyCode = this.getKeyCode(inputContent);
|
||||
var typingContentKeyCode = this.getKeyCode(typingContent);
|
||||
|
||||
if(inputContentKeyCode !== typingContentKeyCode)
|
||||
return false;
|
||||
|
||||
let isShiftInputContent = this.shiftKey.isDown;
|
||||
let isShiftTypingContent = this.keyMapper.isShiftText(typingContent);
|
||||
var isShiftInputContent = this.shiftKey.isDown;
|
||||
var isShiftTypingContent = this.keyMapper.isShiftText(typingContent);
|
||||
|
||||
if(isShiftInputContent !== isShiftTypingContent)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
},
|
||||
|
||||
checkTypingContents(evnet) {
|
||||
let inputContent = event.key;
|
||||
let typingContent = this.typingRandomContents[this.typingIndex];
|
||||
checkTypingContents: function(evnet) {
|
||||
var inputContent = event.key;
|
||||
var typingContent = this.typingRandomContents[this.typingIndex];
|
||||
|
||||
if(this.isKeyPressed(inputContent, typingContent)) {
|
||||
this.typingScore.increase();
|
||||
let animalLevelID = Animal.animalLevelIDByRecord(this.typingScore.score(), Animal.TYPE_PRACTICE);
|
||||
var animalLevelID = Animal.animalLevelIDByRecord(this.typingScore.score(), Animal.TYPE_PRACTICE);
|
||||
if(animalLevelID > this.playingAnimalIndex) {
|
||||
this.playingAnimalIndex = animalLevelID;
|
||||
this.animalOnTitle.setSpecies(Animal.SPECIES_DATA[this.playingAnimalIndex]);;
|
||||
@@ -380,10 +376,9 @@ class TypingPractice {
|
||||
this.animalOnTitle.startAnimation();
|
||||
this.animalOnTitle.tweenAnimation(Animal.ANIMATION_TYPE_DAMAGE);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
playNextContent() {
|
||||
playNextContent: function() {
|
||||
this.hideHighlightKey();
|
||||
|
||||
this.typingIndex++;
|
||||
@@ -391,7 +386,6 @@ class TypingPractice {
|
||||
this.showHighlightKey();
|
||||
this.moveHands();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
+236
-239
@@ -1,266 +1,263 @@
|
||||
class Hand {
|
||||
function Hand(keyMapper) {
|
||||
this.keyMapper = keyMapper;
|
||||
this.pressingFinger = KeyButton.NONE_FINGER;
|
||||
this.prevFingerSprite = null;
|
||||
|
||||
constructor(keyMapper) {
|
||||
this.keyMapper = keyMapper;
|
||||
this.pressingFinger = KeyButton.NONE_FINGER;
|
||||
this.prevFingerSprite = null;
|
||||
this.hand = game.add.image(0, Hand.DEFAULT_Y_PX, "hand_palm");
|
||||
this.hand.anchor.set(0.5);
|
||||
this.hand.scale.set(2);
|
||||
|
||||
this.hand = game.add.image(0, Hand.DEFAULT_Y_PX, "hand_palm");
|
||||
this.hand.anchor.set(0.5);
|
||||
this.hand.scale.set(2);
|
||||
this.thumb = game.add.image(0, 0, "hand_thumb");
|
||||
this.thumb.alpha = 0.5;
|
||||
this.hand.addChild(this.thumb);
|
||||
|
||||
this.thumb = game.add.image(0, 0, "hand_thumb");
|
||||
this.thumb.alpha = 0.5;
|
||||
this.hand.addChild(this.thumb);
|
||||
this.index_finger = game.add.image(0, 0, "hand_index_finger");
|
||||
this.index_finger.alpha = 0.5;
|
||||
this.hand.addChild(this.index_finger);
|
||||
|
||||
this.index_finger = game.add.image(0, 0, "hand_index_finger");
|
||||
this.index_finger.alpha = 0.5;
|
||||
this.hand.addChild(this.index_finger);
|
||||
this.middle_finger = game.add.image(0, 0, "hand_middle_finger");
|
||||
this.middle_finger.alpha = 0.5;
|
||||
this.hand.addChild(this.middle_finger);
|
||||
|
||||
this.middle_finger = game.add.image(0, 0, "hand_middle_finger");
|
||||
this.middle_finger.alpha = 0.5;
|
||||
this.hand.addChild(this.middle_finger);
|
||||
this.ring_filger = game.add.image(0, 0, "hand_little_finger");
|
||||
this.ring_filger.alpha = 0.5;
|
||||
this.hand.addChild(this.ring_filger);
|
||||
|
||||
this.ring_filger = game.add.image(0, 0, "hand_little_finger");
|
||||
this.ring_filger.alpha = 0.5;
|
||||
this.hand.addChild(this.ring_filger);
|
||||
|
||||
this.little_finger = game.add.image(0, 0, "hand_ring_finger");
|
||||
this.little_finger.alpha = 0.5;
|
||||
this.hand.addChild(this.little_finger);
|
||||
|
||||
let mask = game.add.graphics();
|
||||
mask.beginFill(0xffffff);
|
||||
mask.drawRect(100, 300, 1028, 360);
|
||||
this.hand.mask = mask;
|
||||
}
|
||||
|
||||
move(sprite, x, y) {
|
||||
sprite.x = x;
|
||||
sprite.y = y;
|
||||
}
|
||||
|
||||
moveTo(key) {
|
||||
}
|
||||
|
||||
moveToDefaultPosition() {
|
||||
this.moveRow(3, null);
|
||||
this.unhighlightOffFinger(KeyButton.NONE_FINGER);
|
||||
}
|
||||
|
||||
|
||||
moveRow(rowNo, key) {
|
||||
let rowIndex = rowNo - 1;
|
||||
this.hand.y = Hand.DEFAULT_Y_PX + Keyboard.DEFAULT_KEY_SIZE_PX * rowIndex;
|
||||
|
||||
this.moveColumn(rowNo, key);
|
||||
}
|
||||
|
||||
moveColumn(rowNo, key) {
|
||||
}
|
||||
|
||||
|
||||
getFingerSprite(fingerNo) {
|
||||
let fingerSprite = null;
|
||||
switch(fingerNo) {
|
||||
case KeyButton.THUMB:
|
||||
fingerSprite = this.thumb;
|
||||
break;
|
||||
case KeyButton.INDEX_FINGER:
|
||||
case KeyButton.INDEX_FINGER_BASELINE:
|
||||
fingerSprite = this.index_finger;
|
||||
break;
|
||||
case KeyButton.MIDDLE_FINGER:
|
||||
fingerSprite = this.middle_finger;
|
||||
break;
|
||||
case KeyButton.RING_FINGER:
|
||||
fingerSprite = this.ring_filger;
|
||||
break;
|
||||
case KeyButton.LITTLE_FINGER:
|
||||
fingerSprite = this.little_finger;
|
||||
break;
|
||||
}
|
||||
return fingerSprite;
|
||||
}
|
||||
|
||||
highlightOnFinger(fingerNo) {
|
||||
// console.log(fingerNo);
|
||||
let pressingFingerSprite = this.getFingerSprite(fingerNo);
|
||||
if(pressingFingerSprite === this.prevFingerSprite)
|
||||
return;
|
||||
|
||||
if(this.prevFingerSprite !== null)
|
||||
this.unhighlightOffFinger();
|
||||
|
||||
if(pressingFingerSprite !== null) {
|
||||
// console.log(pressingFingerSprite);
|
||||
pressingFingerSprite.tint = 0xffff00;
|
||||
pressingFingerSprite.alpha = 1;
|
||||
}
|
||||
|
||||
this.prevFingerSprite = pressingFingerSprite;
|
||||
}
|
||||
|
||||
unhighlightOffFinger() {
|
||||
if(this.prevFingerSprite === null)
|
||||
return;
|
||||
this.prevFingerSprite.tint = 0xffffff;
|
||||
this.prevFingerSprite.alpha = 0.5;
|
||||
|
||||
this.prevFingerSprite = null;
|
||||
}
|
||||
this.little_finger = game.add.image(0, 0, "hand_ring_finger");
|
||||
this.little_finger.alpha = 0.5;
|
||||
this.hand.addChild(this.little_finger);
|
||||
|
||||
var mask = game.add.graphics();
|
||||
mask.beginFill(0xffffff);
|
||||
mask.drawRect(100, 300, 1028, 360);
|
||||
this.hand.mask = mask;
|
||||
}
|
||||
|
||||
Hand.prototype.move = function(sprite, x, y) {
|
||||
sprite.x = x;
|
||||
sprite.y = y;
|
||||
}
|
||||
|
||||
Hand.prototype.moveTo = function(key) {
|
||||
}
|
||||
|
||||
Hand.prototype.moveToDefaultPosition = function() {
|
||||
this.moveRow(3, null);
|
||||
this.unhighlightOffFinger(KeyButton.NONE_FINGER);
|
||||
}
|
||||
|
||||
|
||||
Hand.prototype.moveRow = function(rowNo, key) {
|
||||
var rowIndex = rowNo - 1;
|
||||
this.hand.y = Hand.DEFAULT_Y_PX + Keyboard.DEFAULT_KEY_SIZE_PX * rowIndex;
|
||||
|
||||
this.moveColumn(rowNo, key);
|
||||
}
|
||||
|
||||
Hand.prototype.moveColumn = function(rowNo, key) {
|
||||
}
|
||||
|
||||
|
||||
Hand.prototype.getFingerSprite = function(fingerNo) {
|
||||
var fingerSprite = null;
|
||||
switch(fingerNo) {
|
||||
case KeyButton.THUMB:
|
||||
fingerSprite = this.thumb;
|
||||
break;
|
||||
case KeyButton.INDEX_FINGER:
|
||||
case KeyButton.INDEX_FINGER_BASELINE:
|
||||
fingerSprite = this.index_finger;
|
||||
break;
|
||||
case KeyButton.MIDDLE_FINGER:
|
||||
fingerSprite = this.middle_finger;
|
||||
break;
|
||||
case KeyButton.RING_FINGER:
|
||||
fingerSprite = this.ring_filger;
|
||||
break;
|
||||
case KeyButton.LITTLE_FINGER:
|
||||
fingerSprite = this.little_finger;
|
||||
break;
|
||||
}
|
||||
return fingerSprite;
|
||||
}
|
||||
|
||||
Hand.prototype.highlightOnFinger = function(fingerNo) {
|
||||
// console.log(fingerNo);
|
||||
var pressingFingerSprite = this.getFingerSprite(fingerNo);
|
||||
if(pressingFingerSprite === this.prevFingerSprite)
|
||||
return;
|
||||
|
||||
if(this.prevFingerSprite !== null)
|
||||
this.unhighlightOffFinger();
|
||||
|
||||
if(pressingFingerSprite !== null) {
|
||||
// console.log(pressingFingerSprite);
|
||||
pressingFingerSprite.tint = 0xffff00;
|
||||
pressingFingerSprite.alpha = 1;
|
||||
}
|
||||
|
||||
this.prevFingerSprite = pressingFingerSprite;
|
||||
}
|
||||
|
||||
Hand.prototype.unhighlightOffFinger = function() {
|
||||
if(this.prevFingerSprite === null)
|
||||
return;
|
||||
this.prevFingerSprite.tint = 0xffffff;
|
||||
this.prevFingerSprite.alpha = 0.5;
|
||||
|
||||
this.prevFingerSprite = null;
|
||||
}
|
||||
|
||||
|
||||
Hand.DEFAULT_Y_PX = 540; // 680;
|
||||
|
||||
|
||||
|
||||
class LeftHand extends Hand {
|
||||
LeftHand.prototype = Object.create(Hand.prototype);
|
||||
LeftHand.constructor = LeftHand;
|
||||
|
||||
constructor(keyMapper) {
|
||||
super(keyMapper);
|
||||
|
||||
this.move(this.thumb, 126, -50);
|
||||
this.move(this.index_finger, 96, -102);
|
||||
this.move(this.middle_finger, 58, -116);
|
||||
this.move(this.ring_filger, 32, -110);
|
||||
this.move(this.little_finger, 4, -106);
|
||||
this.moveToDefaultPosition();
|
||||
}
|
||||
|
||||
moveTo(key) {
|
||||
if(key === undefined)
|
||||
return;
|
||||
|
||||
// console.log(key);
|
||||
let keyCode = this.keyMapper.getKeyIDOfText(key.normalText);
|
||||
|
||||
if(keyCode != "Space")
|
||||
this.moveRow(key.row, key);
|
||||
else
|
||||
this.moveRow(3, key);
|
||||
|
||||
switch(key.keyCode) {
|
||||
case "Key5":
|
||||
case "KeyT":
|
||||
case "KeyG":
|
||||
case "KeyB":
|
||||
this.moveColumn(5, key);
|
||||
break;
|
||||
}
|
||||
|
||||
this.highlightOnFinger(key.fingerType);
|
||||
}
|
||||
|
||||
moveColumn(rowNo, key) {
|
||||
let rowIndex = rowNo - 1;
|
||||
this.hand.x = LeftHand.DEFAULT_X_PX + (Keyboard.DEFAULT_KEY_SIZE_PX / 2) * rowIndex;
|
||||
|
||||
if(key === null)
|
||||
return;
|
||||
|
||||
let keyCode = this.keyMapper.getKeyIDOfText(key.normalText);
|
||||
switch(keyCode) {
|
||||
case "Key5":
|
||||
case "KeyT":
|
||||
case "KeyG":
|
||||
case "KeyB":
|
||||
this.hand.x += Keyboard.DEFAULT_KEY_SIZE_PX;
|
||||
break;
|
||||
|
||||
case "ShiftLeft":
|
||||
this.hand.x = LeftHand.DEFAULT_X_PX;
|
||||
break;
|
||||
}
|
||||
}
|
||||
function LeftHand(keyMapper) {
|
||||
Hand.call(this, keyMapper);
|
||||
|
||||
this.move(this.thumb, 126, -50);
|
||||
this.move(this.index_finger, 96, -102);
|
||||
this.move(this.middle_finger, 58, -116);
|
||||
this.move(this.ring_filger, 32, -110);
|
||||
this.move(this.little_finger, 4, -106);
|
||||
this.moveToDefaultPosition();
|
||||
}
|
||||
|
||||
LeftHand.prototype.moveTo = function(key) {
|
||||
if(key === undefined)
|
||||
return;
|
||||
|
||||
// console.log(key);
|
||||
var keyCode = this.keyMapper.getKeyIDOfText(key.normalText);
|
||||
|
||||
if(keyCode != "Space")
|
||||
this.moveRow(key.row, key);
|
||||
else
|
||||
this.moveRow(3, key);
|
||||
|
||||
switch(key.keyCode) {
|
||||
case "Key5":
|
||||
case "KeyT":
|
||||
case "KeyG":
|
||||
case "KeyB":
|
||||
this.moveColumn(5, key);
|
||||
break;
|
||||
}
|
||||
|
||||
this.highlightOnFinger(key.fingerType);
|
||||
}
|
||||
|
||||
LeftHand.prototype.moveColumn = function(rowNo, key) {
|
||||
var rowIndex = rowNo - 1;
|
||||
this.hand.x = LeftHand.DEFAULT_X_PX + (Keyboard.DEFAULT_KEY_SIZE_PX / 2) * rowIndex;
|
||||
|
||||
if(key === null)
|
||||
return;
|
||||
|
||||
var keyCode = this.keyMapper.getKeyIDOfText(key.normalText);
|
||||
switch(keyCode) {
|
||||
case "Key5":
|
||||
case "KeyT":
|
||||
case "KeyG":
|
||||
case "KeyB":
|
||||
this.hand.x += Keyboard.DEFAULT_KEY_SIZE_PX;
|
||||
break;
|
||||
|
||||
case "ShiftLeft":
|
||||
this.hand.x = LeftHand.DEFAULT_X_PX;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
LeftHand.DEFAULT_X_PX = 100;
|
||||
|
||||
|
||||
|
||||
class RightHand extends Hand {
|
||||
RightHand.prototype = Object.create(Hand.prototype);
|
||||
RightHand.constructor = RightHand;
|
||||
|
||||
constructor(keyMapper) {
|
||||
super(keyMapper);
|
||||
function RightHand(keyMapper) {
|
||||
Hand.call(this, keyMapper);
|
||||
|
||||
this.hand.scale.x *= -1;
|
||||
|
||||
this.move(this.thumb, 126, -50);
|
||||
this.move(this.index_finger, 96, -102);
|
||||
this.move(this.middle_finger, 58, -116);
|
||||
this.move(this.ring_filger, 32, -110);
|
||||
this.move(this.little_finger, 4, -106);
|
||||
this.moveToDefaultPosition();
|
||||
}
|
||||
|
||||
moveTo(key) {
|
||||
if(key === undefined)
|
||||
return;
|
||||
|
||||
// console.log(key);
|
||||
let keyCode = this.keyMapper.getKeyIDOfText(key.normalText);
|
||||
|
||||
if(keyCode != "Space")
|
||||
this.moveRow(key.row, key);
|
||||
else
|
||||
this.moveRow(3, key);
|
||||
|
||||
switch(key.keyCode) {
|
||||
case "Key5":
|
||||
case "KeyT":
|
||||
case "KeyG":
|
||||
case "KeyB":
|
||||
this.moveColumn(5, key);
|
||||
break;
|
||||
}
|
||||
|
||||
this.highlightOnFinger(key.fingerType);
|
||||
}
|
||||
|
||||
moveColumn(rowNo, key) {
|
||||
let rowIndex = rowNo - 1;
|
||||
this.hand.x = RightHand.DEFAULT_X_PX + (Keyboard.DEFAULT_KEY_SIZE_PX / 2) * rowIndex;
|
||||
|
||||
if(key === null)
|
||||
return;
|
||||
|
||||
let keyCode = this.keyMapper.getKeyIDOfText(key.normalText);
|
||||
switch(keyCode) {
|
||||
case "Key6":
|
||||
case "KeyY":
|
||||
case "KeyH":
|
||||
case "KeyN":
|
||||
this.hand.x -= Keyboard.DEFAULT_KEY_SIZE_PX;
|
||||
break;
|
||||
|
||||
case "Minus":
|
||||
case "BracketLeft":
|
||||
case "Quote":
|
||||
this.hand.x += (Keyboard.DEFAULT_KEY_SIZE_PX / 2) * 3;
|
||||
break;
|
||||
|
||||
case "Equal":
|
||||
case "BracketRight":
|
||||
this.hand.x += (Keyboard.DEFAULT_KEY_SIZE_PX / 2) * 5;
|
||||
break;
|
||||
|
||||
case "Backslash":
|
||||
this.hand.x += (Keyboard.DEFAULT_KEY_SIZE_PX / 2) * 7;
|
||||
break;
|
||||
|
||||
case "Enter":
|
||||
this.hand.x = RightHand.DEFAULT_X_PX + (Keyboard.DEFAULT_KEY_SIZE_PX / 2) * 6;
|
||||
break;
|
||||
|
||||
case "ShiftRight":
|
||||
this.hand.x = RightHand.DEFAULT_X_PX + (Keyboard.DEFAULT_KEY_SIZE_PX / 2) * 6;
|
||||
break;
|
||||
}
|
||||
}
|
||||
this.hand.scale.x *= -1;
|
||||
|
||||
this.move(this.thumb, 126, -50);
|
||||
this.move(this.index_finger, 96, -102);
|
||||
this.move(this.middle_finger, 58, -116);
|
||||
this.move(this.ring_filger, 32, -110);
|
||||
this.move(this.little_finger, 4, -106);
|
||||
this.moveToDefaultPosition();
|
||||
}
|
||||
|
||||
RightHand.prototype.moveTo = function(key) {
|
||||
if(key === undefined)
|
||||
return;
|
||||
|
||||
// console.log(key);
|
||||
var keyCode = this.keyMapper.getKeyIDOfText(key.normalText);
|
||||
|
||||
if(keyCode != "Space")
|
||||
this.moveRow(key.row, key);
|
||||
else
|
||||
this.moveRow(3, key);
|
||||
|
||||
switch(key.keyCode) {
|
||||
case "Key5":
|
||||
case "KeyT":
|
||||
case "KeyG":
|
||||
case "KeyB":
|
||||
this.moveColumn(5, key);
|
||||
break;
|
||||
}
|
||||
|
||||
this.highlightOnFinger(key.fingerType);
|
||||
}
|
||||
|
||||
RightHand.prototype.moveColumn = function(rowNo, key) {
|
||||
var rowIndex = rowNo - 1;
|
||||
this.hand.x = RightHand.DEFAULT_X_PX + (Keyboard.DEFAULT_KEY_SIZE_PX / 2) * rowIndex;
|
||||
|
||||
if(key === null)
|
||||
return;
|
||||
|
||||
var keyCode = this.keyMapper.getKeyIDOfText(key.normalText);
|
||||
switch(keyCode) {
|
||||
case "Key6":
|
||||
case "KeyY":
|
||||
case "KeyH":
|
||||
case "KeyN":
|
||||
this.hand.x -= Keyboard.DEFAULT_KEY_SIZE_PX;
|
||||
break;
|
||||
|
||||
case "Minus":
|
||||
case "BracketLeft":
|
||||
case "Quote":
|
||||
this.hand.x += (Keyboard.DEFAULT_KEY_SIZE_PX / 2) * 3;
|
||||
break;
|
||||
|
||||
case "Equal":
|
||||
case "BracketRight":
|
||||
this.hand.x += (Keyboard.DEFAULT_KEY_SIZE_PX / 2) * 5;
|
||||
break;
|
||||
|
||||
case "Backslash":
|
||||
this.hand.x += (Keyboard.DEFAULT_KEY_SIZE_PX / 2) * 7;
|
||||
break;
|
||||
|
||||
case "Enter":
|
||||
this.hand.x = RightHand.DEFAULT_X_PX + (Keyboard.DEFAULT_KEY_SIZE_PX / 2) * 6;
|
||||
break;
|
||||
|
||||
case "ShiftRight":
|
||||
this.hand.x = RightHand.DEFAULT_X_PX + (Keyboard.DEFAULT_KEY_SIZE_PX / 2) * 6;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
RightHand.DEFAULT_X_PX = 810;
|
||||
@@ -1,240 +1,237 @@
|
||||
class KeyButton {
|
||||
function KeyButton(x, y, width, height, normalText, shiftText, handSide, row, fingerType, alignType) {
|
||||
this.normalText = normalText;
|
||||
this.shiftText = shiftText;
|
||||
this.handSide = handSide;
|
||||
this.row = row;
|
||||
this.fingerType = fingerType;
|
||||
this.alignType = alignType;
|
||||
|
||||
constructor(x, y, width, height, normalText, shiftText, handSide, row, fingerType, alignType) {
|
||||
this.normalText = normalText;
|
||||
this.shiftText = shiftText;
|
||||
this.handSide = handSide;
|
||||
this.row = row;
|
||||
this.fingerType = fingerType;
|
||||
this.alignType = alignType;
|
||||
this.setting = new RoundRectButtonSetting(x, y, width, height, KeyButton.DEFALUT_ROUND_AMOUNT_PX);
|
||||
this.setting.strokeWidthPx = 2;
|
||||
|
||||
this.setting = new RoundRectButtonSetting(x, y, width, height, KeyButton.DEFALUT_ROUND_AMOUNT_PX);
|
||||
this.setting.strokeWidthPx = 2;
|
||||
this.buttonSolid = this.makeButtonSolidSprite(this.setting);
|
||||
this.setNormalColor();
|
||||
this.buttonStroke = this.makeButtonStrokeSprite(this.setting);
|
||||
|
||||
this.buttonSolid = this.makeButtonSolidSprite(this.setting);
|
||||
this.setNormalColor();
|
||||
this.buttonStroke = this.makeButtonStrokeSprite(this.setting);
|
||||
|
||||
this.baselineStroke = null;
|
||||
if(fingerType == KeyButton.INDEX_FINGER_BASELINE) {
|
||||
this.baselineStroke = this.makeBaselineStrokeSprite(this.setting, width, height);
|
||||
this.buttonStroke.addChild(this.baselineStroke);
|
||||
}
|
||||
|
||||
this.buttonText = this.makeText(this.setting, this.normalText);
|
||||
if(this.normalText.length > 0) {
|
||||
this.buttonStroke.addChild(this.buttonText);
|
||||
}
|
||||
|
||||
this.highlightButtonStroke = this.makeHighlightButtonStrokeSprite(this.setting);
|
||||
this.highlightButtonStroke.alpha = 0;
|
||||
this.baselineStroke = null;
|
||||
if(fingerType == KeyButton.INDEX_FINGER_BASELINE) {
|
||||
this.baselineStroke = this.makeBaselineStrokeSprite(this.setting, width, height);
|
||||
this.buttonStroke.addChild(this.baselineStroke);
|
||||
}
|
||||
|
||||
makeButtonSolidSprite(setting) {
|
||||
let btnTexture = new Phaser.Graphics()
|
||||
.beginFill(0xffffff, 0.5)
|
||||
// .lineStyle(setting.strokeWidthPx, 0xFFffff, 1)
|
||||
.drawRoundedRect(0, 0, setting.width, setting.height, setting.roundAmount)
|
||||
.endFill()
|
||||
.generateTexture();
|
||||
|
||||
return game.add.sprite(
|
||||
setting.x, // - setting.width / 2,
|
||||
setting.y, // - setting.height / 2,
|
||||
btnTexture
|
||||
);
|
||||
}
|
||||
|
||||
makeButtonStrokeSprite(setting) {
|
||||
let btnTexture = new Phaser.Graphics()
|
||||
.lineStyle(setting.strokeWidthPx, 0xaaaaaa, 1)
|
||||
.drawRoundedRect(0, 0, setting.width, setting.height, setting.roundAmount)
|
||||
.generateTexture();
|
||||
|
||||
return game.add.sprite(
|
||||
setting.x, // - setting.width / 2,
|
||||
setting.y, // - setting.height / 2,
|
||||
btnTexture
|
||||
);
|
||||
}
|
||||
|
||||
makeHighlightButtonStrokeSprite(setting) {
|
||||
let strokeWidth = setting.strokeWidthPx * 2;
|
||||
let btnTexture = new Phaser.Graphics()
|
||||
.lineStyle(strokeWidth, 0xfffff00, 1)
|
||||
.drawRoundedRect(0, 0, setting.width, setting.height, setting.roundAmount)
|
||||
.generateTexture();
|
||||
|
||||
return game.add.sprite(
|
||||
setting.x - strokeWidth / 4,
|
||||
setting.y - strokeWidth / 4,
|
||||
btnTexture
|
||||
);
|
||||
}
|
||||
|
||||
makeBaselineStrokeSprite(setting, width, height) {
|
||||
let strokePx = setting.strokeWidthPx;
|
||||
|
||||
let baselineTexture = new Phaser.Graphics()
|
||||
.lineStyle(2, 0x888888)
|
||||
.moveTo(1, 1)
|
||||
.lineTo(16, 1)
|
||||
.lineStyle(2, 0xffffff)
|
||||
.moveTo(0, 0)
|
||||
.lineTo(15, 0)
|
||||
.generateTexture();
|
||||
|
||||
let baselineSprite = game.add.sprite(
|
||||
strokePx + setting.width / 2,
|
||||
strokePx + setting.height - 6,
|
||||
baselineTexture
|
||||
);
|
||||
baselineSprite.anchor.set(0.5);
|
||||
return baselineSprite;
|
||||
}
|
||||
|
||||
makeText(setting, textContent) {
|
||||
let fontStyle = { };
|
||||
if(this.alignType === KeyButton.NORMAL_KEY)
|
||||
setting.fontStyle.font = "20px Courier New";
|
||||
else
|
||||
setting.fontStyle.font = "11px Courier New";
|
||||
|
||||
let OFFSET_X = 4, OFFSET_Y = 3;
|
||||
let textPosX = 0, textPosY = 0;
|
||||
switch(this.alignType) {
|
||||
case KeyButton.NORMAL_KEY:
|
||||
case KeyButton.NORMAL_FUNCTION_KEY:
|
||||
textPosX = setting.strokeWidthPx + setting.width / 2;
|
||||
textPosY = setting.strokeWidthPx + setting.height / 2 + OFFSET_Y;
|
||||
break;
|
||||
|
||||
case KeyButton.LEFT_FUNCTION_KEY:
|
||||
textPosX = setting.strokeWidthPx + OFFSET_X;
|
||||
textPosY = setting.strokeWidthPx + setting.height;
|
||||
break;
|
||||
|
||||
case KeyButton.CENTER_FUNCTION_KEY:
|
||||
textPosX = setting.strokeWidthPx + setting.width / 2;
|
||||
textPosY = setting.strokeWidthPx + setting.height;
|
||||
break;
|
||||
|
||||
case KeyButton.RIGHT_FUNCTION_KEY:
|
||||
textPosX = setting.strokeWidthPx + setting.width - OFFSET_X;
|
||||
textPosY = setting.strokeWidthPx + setting.height;
|
||||
break;
|
||||
}
|
||||
|
||||
let buttonText = game.add.text(textPosX, textPosY, textContent, setting.fontStyle);
|
||||
switch(this.alignType) {
|
||||
case KeyButton.NORMAL_KEY:
|
||||
case KeyButton.NORMAL_FUNCTION_KEY:
|
||||
buttonText.anchor.set(0.5);
|
||||
break;
|
||||
|
||||
case KeyButton.LEFT_FUNCTION_KEY:
|
||||
buttonText.anchor.set(0, 1);
|
||||
break;
|
||||
|
||||
case KeyButton.CENTER_FUNCTION_KEY:
|
||||
buttonText.anchor.set(0.5, 1);
|
||||
break;
|
||||
|
||||
case KeyButton.RIGHT_FUNCTION_KEY:
|
||||
buttonText.anchor.set(1, 1);
|
||||
break;
|
||||
}
|
||||
|
||||
return buttonText;
|
||||
}
|
||||
|
||||
|
||||
setNormalColor() {
|
||||
switch(this.fingerType) {
|
||||
case KeyButton.THUMB:
|
||||
this.buttonSolid.tint = 0x604d4d;
|
||||
break;
|
||||
|
||||
case KeyButton.INDEX_FINGER:
|
||||
case KeyButton.INDEX_FINGER_BASELINE:
|
||||
this.buttonSolid.tint = 0x4d604d;
|
||||
break;
|
||||
|
||||
case KeyButton.MIDDLE_FINGER:
|
||||
this.buttonSolid.tint = 0x4d4d60;
|
||||
break;
|
||||
|
||||
case KeyButton.RING_FINGER:
|
||||
this.buttonSolid.tint = 0x60604d;
|
||||
break;
|
||||
|
||||
case KeyButton.LITTLE_FINGER:
|
||||
this.buttonSolid.tint = 0x4d6060;
|
||||
break;
|
||||
|
||||
default:
|
||||
this.buttonSolid.tint = 0x4d4d4d;
|
||||
// this.buttonSolid.alpha = 0;
|
||||
}
|
||||
}
|
||||
|
||||
setTargetColor() {
|
||||
switch(this.fingerType) {
|
||||
case KeyButton.THUMB:
|
||||
this.buttonSolid.tint = 0xff8080;
|
||||
break;
|
||||
|
||||
case KeyButton.INDEX_FINGER:
|
||||
case KeyButton.INDEX_FINGER_BASELINE:
|
||||
this.buttonSolid.tint = 0x80ff80;
|
||||
break;
|
||||
|
||||
case KeyButton.MIDDLE_FINGER:
|
||||
this.buttonSolid.tint = 0x8080ff;
|
||||
break;
|
||||
|
||||
case KeyButton.RING_FINGER:
|
||||
this.buttonSolid.tint = 0xffff80;
|
||||
break;
|
||||
|
||||
case KeyButton.LITTLE_FINGER:
|
||||
this.buttonSolid.tint = 0x80ffff;
|
||||
break;
|
||||
|
||||
default:
|
||||
this.buttonSolid.tint = 0x202020;
|
||||
// this.buttonSolid.alpha = 0;
|
||||
}
|
||||
}
|
||||
|
||||
setGoodPressColor() {
|
||||
this.buttonSolid.tint = 0x0000ff;
|
||||
}
|
||||
|
||||
setBadPressColor() {
|
||||
this.buttonSolid.tint = 0xff0000;
|
||||
}
|
||||
|
||||
|
||||
showHighlight() {
|
||||
this.highlightButtonStroke.alpha = 1;
|
||||
}
|
||||
|
||||
hideHighlight() {
|
||||
this.highlightButtonStroke.alpha = 0;
|
||||
}
|
||||
|
||||
|
||||
onShiftPressed() {
|
||||
this.buttonText.text = this.shiftText;
|
||||
}
|
||||
|
||||
onShiftUnpressed() {
|
||||
this.buttonText.text = this.normalText;
|
||||
this.buttonText = this.makeText(this.setting, this.normalText);
|
||||
if(this.normalText.length > 0) {
|
||||
this.buttonStroke.addChild(this.buttonText);
|
||||
}
|
||||
|
||||
this.highlightButtonStroke = this.makeHighlightButtonStrokeSprite(this.setting);
|
||||
this.highlightButtonStroke.alpha = 0;
|
||||
}
|
||||
|
||||
KeyButton.prototype.makeButtonSolidSprite = function(setting) {
|
||||
var btnTexture = new Phaser.Graphics()
|
||||
.beginFill(0xffffff, 0.5)
|
||||
// .lineStyle(setting.strokeWidthPx, 0xFFffff, 1)
|
||||
.drawRoundedRect(0, 0, setting.width, setting.height, setting.roundAmount)
|
||||
.endFill()
|
||||
.generateTexture();
|
||||
|
||||
return game.add.sprite(
|
||||
setting.x, // - setting.width / 2,
|
||||
setting.y, // - setting.height / 2,
|
||||
btnTexture
|
||||
);
|
||||
}
|
||||
|
||||
KeyButton.prototype.makeButtonStrokeSprite = function(setting) {
|
||||
var btnTexture = new Phaser.Graphics()
|
||||
.lineStyle(setting.strokeWidthPx, 0xaaaaaa, 1)
|
||||
.drawRoundedRect(0, 0, setting.width, setting.height, setting.roundAmount)
|
||||
.generateTexture();
|
||||
|
||||
return game.add.sprite(
|
||||
setting.x, // - setting.width / 2,
|
||||
setting.y, // - setting.height / 2,
|
||||
btnTexture
|
||||
);
|
||||
}
|
||||
|
||||
KeyButton.prototype.makeHighlightButtonStrokeSprite = function(setting) {
|
||||
var strokeWidth = setting.strokeWidthPx * 2;
|
||||
var btnTexture = new Phaser.Graphics()
|
||||
.lineStyle(strokeWidth, 0xfffff00, 1)
|
||||
.drawRoundedRect(0, 0, setting.width, setting.height, setting.roundAmount)
|
||||
.generateTexture();
|
||||
|
||||
return game.add.sprite(
|
||||
setting.x - strokeWidth / 4,
|
||||
setting.y - strokeWidth / 4,
|
||||
btnTexture
|
||||
);
|
||||
}
|
||||
|
||||
KeyButton.prototype.makeBaselineStrokeSprite = function(setting, width, height) {
|
||||
var strokePx = setting.strokeWidthPx;
|
||||
|
||||
var baselineTexture = new Phaser.Graphics()
|
||||
.lineStyle(2, 0x888888)
|
||||
.moveTo(1, 1)
|
||||
.lineTo(16, 1)
|
||||
.lineStyle(2, 0xffffff)
|
||||
.moveTo(0, 0)
|
||||
.lineTo(15, 0)
|
||||
.generateTexture();
|
||||
|
||||
var baselineSprite = game.add.sprite(
|
||||
strokePx + setting.width / 2,
|
||||
strokePx + setting.height - 6,
|
||||
baselineTexture
|
||||
);
|
||||
baselineSprite.anchor.set(0.5);
|
||||
return baselineSprite;
|
||||
}
|
||||
|
||||
KeyButton.prototype.makeText = function(setting, textContent) {
|
||||
var fontStyle = { };
|
||||
if(this.alignType === KeyButton.NORMAL_KEY)
|
||||
setting.fontStyle.font = "20px Courier New";
|
||||
else
|
||||
setting.fontStyle.font = "11px Courier New";
|
||||
|
||||
var OFFSET_X = 4, OFFSET_Y = 3;
|
||||
var textPosX = 0, textPosY = 0;
|
||||
switch(this.alignType) {
|
||||
case KeyButton.NORMAL_KEY:
|
||||
case KeyButton.NORMAL_FUNCTION_KEY:
|
||||
textPosX = setting.strokeWidthPx + setting.width / 2;
|
||||
textPosY = setting.strokeWidthPx + setting.height / 2 + OFFSET_Y;
|
||||
break;
|
||||
|
||||
case KeyButton.LEFT_FUNCTION_KEY:
|
||||
textPosX = setting.strokeWidthPx + OFFSET_X;
|
||||
textPosY = setting.strokeWidthPx + setting.height;
|
||||
break;
|
||||
|
||||
case KeyButton.CENTER_FUNCTION_KEY:
|
||||
textPosX = setting.strokeWidthPx + setting.width / 2;
|
||||
textPosY = setting.strokeWidthPx + setting.height;
|
||||
break;
|
||||
|
||||
case KeyButton.RIGHT_FUNCTION_KEY:
|
||||
textPosX = setting.strokeWidthPx + setting.width - OFFSET_X;
|
||||
textPosY = setting.strokeWidthPx + setting.height;
|
||||
break;
|
||||
}
|
||||
|
||||
var buttonText = game.add.text(textPosX, textPosY, textContent, setting.fontStyle);
|
||||
switch(this.alignType) {
|
||||
case KeyButton.NORMAL_KEY:
|
||||
case KeyButton.NORMAL_FUNCTION_KEY:
|
||||
buttonText.anchor.set(0.5);
|
||||
break;
|
||||
|
||||
case KeyButton.LEFT_FUNCTION_KEY:
|
||||
buttonText.anchor.set(0, 1);
|
||||
break;
|
||||
|
||||
case KeyButton.CENTER_FUNCTION_KEY:
|
||||
buttonText.anchor.set(0.5, 1);
|
||||
break;
|
||||
|
||||
case KeyButton.RIGHT_FUNCTION_KEY:
|
||||
buttonText.anchor.set(1, 1);
|
||||
break;
|
||||
}
|
||||
|
||||
return buttonText;
|
||||
}
|
||||
|
||||
|
||||
KeyButton.prototype.setNormalColor = function() {
|
||||
switch(this.fingerType) {
|
||||
case KeyButton.THUMB:
|
||||
this.buttonSolid.tint = 0x604d4d;
|
||||
break;
|
||||
|
||||
case KeyButton.INDEX_FINGER:
|
||||
case KeyButton.INDEX_FINGER_BASELINE:
|
||||
this.buttonSolid.tint = 0x4d604d;
|
||||
break;
|
||||
|
||||
case KeyButton.MIDDLE_FINGER:
|
||||
this.buttonSolid.tint = 0x4d4d60;
|
||||
break;
|
||||
|
||||
case KeyButton.RING_FINGER:
|
||||
this.buttonSolid.tint = 0x60604d;
|
||||
break;
|
||||
|
||||
case KeyButton.LITTLE_FINGER:
|
||||
this.buttonSolid.tint = 0x4d6060;
|
||||
break;
|
||||
|
||||
default:
|
||||
this.buttonSolid.tint = 0x4d4d4d;
|
||||
// this.buttonSolid.alpha = 0;
|
||||
}
|
||||
}
|
||||
|
||||
KeyButton.prototype.setTargetColor = function() {
|
||||
switch(this.fingerType) {
|
||||
case KeyButton.THUMB:
|
||||
this.buttonSolid.tint = 0xff8080;
|
||||
break;
|
||||
|
||||
case KeyButton.INDEX_FINGER:
|
||||
case KeyButton.INDEX_FINGER_BASELINE:
|
||||
this.buttonSolid.tint = 0x80ff80;
|
||||
break;
|
||||
|
||||
case KeyButton.MIDDLE_FINGER:
|
||||
this.buttonSolid.tint = 0x8080ff;
|
||||
break;
|
||||
|
||||
case KeyButton.RING_FINGER:
|
||||
this.buttonSolid.tint = 0xffff80;
|
||||
break;
|
||||
|
||||
case KeyButton.LITTLE_FINGER:
|
||||
this.buttonSolid.tint = 0x80ffff;
|
||||
break;
|
||||
|
||||
default:
|
||||
this.buttonSolid.tint = 0x202020;
|
||||
// this.buttonSolid.alpha = 0;
|
||||
}
|
||||
}
|
||||
|
||||
KeyButton.prototype.setGoodPressColor = function() {
|
||||
this.buttonSolid.tint = 0x0000ff;
|
||||
}
|
||||
|
||||
KeyButton.prototype.setBadPressColor = function() {
|
||||
this.buttonSolid.tint = 0xff0000;
|
||||
}
|
||||
|
||||
|
||||
KeyButton.prototype.showHighlight = function() {
|
||||
this.highlightButtonStroke.alpha = 1;
|
||||
}
|
||||
|
||||
KeyButton.prototype.hideHighlight = function() {
|
||||
this.highlightButtonStroke.alpha = 0;
|
||||
}
|
||||
|
||||
|
||||
KeyButton.prototype.onShiftPressed = function() {
|
||||
this.buttonText.text = this.shiftText;
|
||||
}
|
||||
|
||||
KeyButton.prototype.onShiftUnpressed = function() {
|
||||
this.buttonText.text = this.normalText;
|
||||
}
|
||||
|
||||
|
||||
KeyButton.NONE_ICON = "";
|
||||
KeyButton.NONE_BUTTON_TEXT = "";
|
||||
|
||||
|
||||
@@ -1,249 +1,237 @@
|
||||
class KeyData {
|
||||
function KeyData() {
|
||||
this.functionKey = null;
|
||||
this.englishKey = null;
|
||||
this.koreanKey = null;
|
||||
}
|
||||
|
||||
constructor() {
|
||||
this.functionKey = null;
|
||||
this.englishKey = null;
|
||||
this.koreanKey = null;
|
||||
function KeyTextData(normalText, shiftText) {
|
||||
this.normalText = normalText;
|
||||
this.shiftText = shiftText;
|
||||
}
|
||||
|
||||
|
||||
function KeyMapper() {
|
||||
this.keyboardKeyMap = {};
|
||||
this.inputKeyMap = {};
|
||||
|
||||
this.registerFunctionKey();
|
||||
this.registerEnglishKey();
|
||||
this.registerKoreanKey();
|
||||
}
|
||||
|
||||
|
||||
KeyMapper.prototype.registerFunctionKey = function() {
|
||||
this.registerFunctionKeyTextData("Backquote", "`", "~");
|
||||
this.registerFunctionKeyTextData("Digit1", "1", "!");
|
||||
this.registerFunctionKeyTextData("Digit2", "2", "@");
|
||||
this.registerFunctionKeyTextData("Digit3", "3", "#");
|
||||
this.registerFunctionKeyTextData("Digit4", "4", "$");
|
||||
this.registerFunctionKeyTextData("Digit5", "5", "%");
|
||||
this.registerFunctionKeyTextData("Digit6", "6", "^");
|
||||
this.registerFunctionKeyTextData("Digit7", "7", "&");
|
||||
this.registerFunctionKeyTextData("Digit8", "8", "*");
|
||||
this.registerFunctionKeyTextData("Digit9", "9", "(");
|
||||
this.registerFunctionKeyTextData("Digit0", "0", ")");
|
||||
this.registerFunctionKeyTextData("Minus", "-", "_");
|
||||
this.registerFunctionKeyTextData("Equal", "=", "+");
|
||||
this.registerFunctionKeyTextData("Backspace", "backspace", "backspace");
|
||||
|
||||
this.registerFunctionKeyTextData("Tab", "tab", "tab");
|
||||
this.registerFunctionKeyTextData("BracketLeft", "[", "{");
|
||||
this.registerFunctionKeyTextData("BracketRight", "]", "}");
|
||||
this.registerFunctionKeyTextData("Backslash", "\\", "|");
|
||||
|
||||
this.registerFunctionKeyTextData("CapsLock", "caps lock", "caps lock");
|
||||
this.registerFunctionKeyTextData("Semicolon", ";", ":");
|
||||
this.registerFunctionKeyTextData("Quote", "'", "\"");
|
||||
this.registerFunctionKeyTextData("Enter", "enter", "enter");
|
||||
|
||||
this.registerFunctionKeyTextData("ShiftLeft", "left_shift", "left_shift");
|
||||
this.registerFunctionKeyTextData("ShiftRight", "right_shift", "right_shift");
|
||||
this.registerFunctionKeyTextData("Comma", ",", "<");
|
||||
this.registerFunctionKeyTextData("Period", ".", ">");
|
||||
this.registerFunctionKeyTextData("Slash", "/", "?");
|
||||
|
||||
this.registerFunctionKeyTextData("ControlLeft", "ctrl", "ctrl");
|
||||
this.registerFunctionKeyTextData("window", "window", "window");
|
||||
this.registerFunctionKeyTextData("AltLeft", "alt", "alt");
|
||||
this.registerFunctionKeyTextData("Chinese", "한자", "한자");
|
||||
this.registerFunctionKeyTextData("Space", "space", "space");
|
||||
this.registerFunctionKeyTextData("KoreanEnglish", "한/영", "한/영");
|
||||
this.registerFunctionKeyTextData("AltRight", "alt", "alt");
|
||||
this.registerFunctionKeyTextData("ControlRight", "ctrl", "ctrl");
|
||||
}
|
||||
|
||||
KeyMapper.prototype.registerEnglishKey = function() {
|
||||
this.registerEnglishKeyTextData("KeyQ", "q", "Q");
|
||||
this.registerEnglishKeyTextData("KeyW", "w", "W");
|
||||
this.registerEnglishKeyTextData("KeyE", "e", "E");
|
||||
this.registerEnglishKeyTextData("KeyR", "r", "R");
|
||||
this.registerEnglishKeyTextData("KeyT", "t", "T");
|
||||
this.registerEnglishKeyTextData("KeyY", "y", "Y");
|
||||
this.registerEnglishKeyTextData("KeyU", "u", "U");
|
||||
this.registerEnglishKeyTextData("KeyI", "i", "I");
|
||||
this.registerEnglishKeyTextData("KeyO", "o", "O");
|
||||
this.registerEnglishKeyTextData("KeyP", "p", "P");
|
||||
|
||||
this.registerEnglishKeyTextData("KeyA", "a", "A");
|
||||
this.registerEnglishKeyTextData("KeyS", "s", "S");
|
||||
this.registerEnglishKeyTextData("KeyD", "d", "D");
|
||||
this.registerEnglishKeyTextData("KeyF", "f", "F");
|
||||
this.registerEnglishKeyTextData("KeyG", "g", "G");
|
||||
this.registerEnglishKeyTextData("KeyH", "h", "H");
|
||||
this.registerEnglishKeyTextData("KeyJ", "j", "J");
|
||||
this.registerEnglishKeyTextData("KeyK", "k", "K");
|
||||
this.registerEnglishKeyTextData("KeyL", "l", "L");
|
||||
|
||||
this.registerEnglishKeyTextData("KeyZ", "z", "Z");
|
||||
this.registerEnglishKeyTextData("KeyX", "x", "X");
|
||||
this.registerEnglishKeyTextData("KeyC", "c", "C");
|
||||
this.registerEnglishKeyTextData("KeyV", "v", "V");
|
||||
this.registerEnglishKeyTextData("KeyB", "b", "B");
|
||||
this.registerEnglishKeyTextData("KeyN", "n", "N");
|
||||
this.registerEnglishKeyTextData("KeyM", "m", "M");
|
||||
}
|
||||
|
||||
KeyMapper.prototype.registerKoreanKey = function() {
|
||||
this.registerKoreanKeyTextData("KeyQ", "ㅂ", "ㅃ");
|
||||
this.registerKoreanKeyTextData("KeyW", "ㅈ", "ㅉ");
|
||||
this.registerKoreanKeyTextData("KeyE", "ㄷ", "ㄸ");
|
||||
this.registerKoreanKeyTextData("KeyR", "ㄱ", "ㄲ");
|
||||
this.registerKoreanKeyTextData("KeyT", "ㅅ", "ㅆ");
|
||||
this.registerKoreanKeyTextData("KeyY", "ㅛ", "ㅛ");
|
||||
this.registerKoreanKeyTextData("KeyU", "ㅕ", "ㅕ");
|
||||
this.registerKoreanKeyTextData("KeyI", "ㅑ", "ㅑ");
|
||||
this.registerKoreanKeyTextData("KeyO", "ㅐ", "ㅒ");
|
||||
this.registerKoreanKeyTextData("KeyP", "ㅔ", "ㅖ");
|
||||
|
||||
this.registerKoreanKeyTextData("KeyA", "ㅁ", "ㅁ");
|
||||
this.registerKoreanKeyTextData("KeyS", "ㄴ", "ㄴ");
|
||||
this.registerKoreanKeyTextData("KeyD", "ㅇ", "ㅇ");
|
||||
this.registerKoreanKeyTextData("KeyF", "ㄹ", "ㄹ");
|
||||
this.registerKoreanKeyTextData("KeyG", "ㅎ", "ㅎ");
|
||||
this.registerKoreanKeyTextData("KeyH", "ㅗ", "ㅗ");
|
||||
this.registerKoreanKeyTextData("KeyJ", "ㅓ", "ㅓ");
|
||||
this.registerKoreanKeyTextData("KeyK", "ㅏ", "ㅏ");
|
||||
this.registerKoreanKeyTextData("KeyL", "ㅣ", "ㅣ");
|
||||
|
||||
this.registerKoreanKeyTextData("KeyZ", "ㅋ", "ㅋ");
|
||||
this.registerKoreanKeyTextData("KeyX", "ㅌ", "ㅌ");
|
||||
this.registerKoreanKeyTextData("KeyC", "ㅊ", "ㅊ");
|
||||
this.registerKoreanKeyTextData("KeyV", "ㅍ", "ㅍ");
|
||||
this.registerKoreanKeyTextData("KeyB", "ㅠ", "ㅠ");
|
||||
this.registerKoreanKeyTextData("KeyN", "ㅜ", "ㅜ");
|
||||
this.registerKoreanKeyTextData("KeyM", "ㅡ", "ㅡ");
|
||||
}
|
||||
|
||||
|
||||
KeyMapper.prototype.registerFunctionKeyTextData = function(keyID, normalText, shiftText) {
|
||||
if(this.keyboardKeyMap[keyID] === undefined) {
|
||||
this.keyboardKeyMap[keyID] = new KeyData();
|
||||
}
|
||||
this.keyboardKeyMap[keyID].functionKey = new KeyTextData(normalText, shiftText);
|
||||
|
||||
if(this.inputKeyMap[keyID] === undefined)
|
||||
this.inputKeyMap[keyID] = keyID;
|
||||
if(this.inputKeyMap[normalText] === undefined)
|
||||
this.inputKeyMap[normalText] = keyID;
|
||||
if(this.inputKeyMap[shiftText] === undefined)
|
||||
this.inputKeyMap[shiftText] = keyID;
|
||||
}
|
||||
|
||||
KeyMapper.prototype.registerEnglishKeyTextData = function(keyID, normalText, shiftText) {
|
||||
if(this.keyboardKeyMap[keyID] === undefined) {
|
||||
this.keyboardKeyMap[keyID] = new KeyData();
|
||||
}
|
||||
this.keyboardKeyMap[keyID].englishKey = new KeyTextData(normalText, shiftText);
|
||||
|
||||
if(this.inputKeyMap[keyID] === undefined)
|
||||
this.inputKeyMap[keyID] = keyID;
|
||||
if(this.inputKeyMap[normalText] === undefined)
|
||||
this.inputKeyMap[normalText] = keyID;
|
||||
if(this.inputKeyMap[shiftText] === undefined)
|
||||
this.inputKeyMap[shiftText] = keyID;
|
||||
}
|
||||
|
||||
KeyMapper.prototype.registerKoreanKeyTextData = function(keyID, normalText, shiftText) {
|
||||
if(this.keyboardKeyMap[keyID] === undefined) {
|
||||
this.keyboardKeyMap[keyID] = new KeyData();
|
||||
}
|
||||
this.keyboardKeyMap[keyID].koreanKey = new KeyTextData(normalText, shiftText);
|
||||
|
||||
if(this.inputKeyMap[keyID] === undefined)
|
||||
this.inputKeyMap[keyID] = keyID;
|
||||
if(this.inputKeyMap[normalText] === undefined)
|
||||
this.inputKeyMap[normalText] = keyID;
|
||||
if(this.inputKeyMap[shiftText] === undefined)
|
||||
this.inputKeyMap[shiftText] = keyID;
|
||||
}
|
||||
|
||||
|
||||
KeyMapper.prototype.getNormalText = function(keyID, language) {
|
||||
if(this.keyboardKeyMap[keyID] === undefined) {
|
||||
console.log(keyID);
|
||||
return "?";
|
||||
}
|
||||
|
||||
// console.log(keyID);
|
||||
// console.log(language);
|
||||
// console.log(this.keyboardKeyMap[keyID]);
|
||||
var keyData = this.keyboardKeyMap[keyID];
|
||||
if(language === Keyboard.ENGLISH && keyData.englishKey !== null) {
|
||||
return keyData.englishKey.normalText;
|
||||
}
|
||||
else if(language === Keyboard.KOREAN && keyData.koreanKey !== null) {
|
||||
return keyData.koreanKey.normalText;
|
||||
}
|
||||
else if(keyData.functionKey !== undefined) {
|
||||
return keyData.functionKey.normalText;
|
||||
}
|
||||
else {
|
||||
return "?";
|
||||
}
|
||||
}
|
||||
|
||||
class KeyTextData {
|
||||
|
||||
constructor(normalText, shiftText) {
|
||||
this.normalText = normalText;
|
||||
this.shiftText = shiftText;
|
||||
KeyMapper.prototype.getShiftText = function(keyID, language) {
|
||||
if(this.keyboardKeyMap[keyID] === undefined) {
|
||||
console.log(keyID);
|
||||
return "?";
|
||||
}
|
||||
|
||||
// console.log(keyID);
|
||||
// console.log(language);
|
||||
// console.log(this.keyboardKeyMap[keyID]);
|
||||
var keyData = this.keyboardKeyMap[keyID];
|
||||
if(language === Keyboard.ENGLISH && keyData.englishKey !== null) {
|
||||
return keyData.englishKey.shiftText;
|
||||
}
|
||||
else if(language === Keyboard.KOREAN && keyData.koreanKey !== null) {
|
||||
return keyData.koreanKey.shiftText;
|
||||
}
|
||||
else if(keyData.functionKey !== undefined) {
|
||||
return keyData.functionKey.shiftText;
|
||||
}
|
||||
else {
|
||||
return "?";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
class KeyMapper {
|
||||
|
||||
constructor() {
|
||||
this.keyboardKeyMap = {};
|
||||
this.inputKeyMap = {};
|
||||
|
||||
this.registerFunctionKey();
|
||||
this.registerEnglishKey();
|
||||
this.registerKoreanKey();
|
||||
}
|
||||
|
||||
|
||||
registerFunctionKey() {
|
||||
this.registerFunctionKeyTextData("Backquote", "`", "~");
|
||||
this.registerFunctionKeyTextData("Digit1", "1", "!");
|
||||
this.registerFunctionKeyTextData("Digit2", "2", "@");
|
||||
this.registerFunctionKeyTextData("Digit3", "3", "#");
|
||||
this.registerFunctionKeyTextData("Digit4", "4", "$");
|
||||
this.registerFunctionKeyTextData("Digit5", "5", "%");
|
||||
this.registerFunctionKeyTextData("Digit6", "6", "^");
|
||||
this.registerFunctionKeyTextData("Digit7", "7", "&");
|
||||
this.registerFunctionKeyTextData("Digit8", "8", "*");
|
||||
this.registerFunctionKeyTextData("Digit9", "9", "(");
|
||||
this.registerFunctionKeyTextData("Digit0", "0", ")");
|
||||
this.registerFunctionKeyTextData("Minus", "-", "_");
|
||||
this.registerFunctionKeyTextData("Equal", "=", "+");
|
||||
this.registerFunctionKeyTextData("Backspace", "backspace", "backspace");
|
||||
|
||||
this.registerFunctionKeyTextData("Tab", "tab", "tab");
|
||||
this.registerFunctionKeyTextData("BracketLeft", "[", "{");
|
||||
this.registerFunctionKeyTextData("BracketRight", "]", "}");
|
||||
this.registerFunctionKeyTextData("Backslash", "\\", "|");
|
||||
|
||||
this.registerFunctionKeyTextData("CapsLock", "caps lock", "caps lock");
|
||||
this.registerFunctionKeyTextData("Semicolon", ";", ":");
|
||||
this.registerFunctionKeyTextData("Quote", "'", "\"");
|
||||
this.registerFunctionKeyTextData("Enter", "enter", "enter");
|
||||
|
||||
this.registerFunctionKeyTextData("ShiftLeft", "left_shift", "left_shift");
|
||||
this.registerFunctionKeyTextData("ShiftRight", "right_shift", "right_shift");
|
||||
this.registerFunctionKeyTextData("Comma", ",", "<");
|
||||
this.registerFunctionKeyTextData("Period", ".", ">");
|
||||
this.registerFunctionKeyTextData("Slash", "/", "?");
|
||||
|
||||
this.registerFunctionKeyTextData("ControlLeft", "ctrl", "ctrl");
|
||||
this.registerFunctionKeyTextData("window", "window", "window");
|
||||
this.registerFunctionKeyTextData("AltLeft", "alt", "alt");
|
||||
this.registerFunctionKeyTextData("Chinese", "한자", "한자");
|
||||
this.registerFunctionKeyTextData("Space", "space", "space");
|
||||
this.registerFunctionKeyTextData("KoreanEnglish", "한/영", "한/영");
|
||||
this.registerFunctionKeyTextData("AltRight", "alt", "alt");
|
||||
this.registerFunctionKeyTextData("ControlRight", "ctrl", "ctrl");
|
||||
}
|
||||
|
||||
registerEnglishKey() {
|
||||
this.registerEnglishKeyTextData("KeyQ", "q", "Q");
|
||||
this.registerEnglishKeyTextData("KeyW", "w", "W");
|
||||
this.registerEnglishKeyTextData("KeyE", "e", "E");
|
||||
this.registerEnglishKeyTextData("KeyR", "r", "R");
|
||||
this.registerEnglishKeyTextData("KeyT", "t", "T");
|
||||
this.registerEnglishKeyTextData("KeyY", "y", "Y");
|
||||
this.registerEnglishKeyTextData("KeyU", "u", "U");
|
||||
this.registerEnglishKeyTextData("KeyI", "i", "I");
|
||||
this.registerEnglishKeyTextData("KeyO", "o", "O");
|
||||
this.registerEnglishKeyTextData("KeyP", "p", "P");
|
||||
|
||||
this.registerEnglishKeyTextData("KeyA", "a", "A");
|
||||
this.registerEnglishKeyTextData("KeyS", "s", "S");
|
||||
this.registerEnglishKeyTextData("KeyD", "d", "D");
|
||||
this.registerEnglishKeyTextData("KeyF", "f", "F");
|
||||
this.registerEnglishKeyTextData("KeyG", "g", "G");
|
||||
this.registerEnglishKeyTextData("KeyH", "h", "H");
|
||||
this.registerEnglishKeyTextData("KeyJ", "j", "J");
|
||||
this.registerEnglishKeyTextData("KeyK", "k", "K");
|
||||
this.registerEnglishKeyTextData("KeyL", "l", "L");
|
||||
|
||||
this.registerEnglishKeyTextData("KeyZ", "z", "Z");
|
||||
this.registerEnglishKeyTextData("KeyX", "x", "X");
|
||||
this.registerEnglishKeyTextData("KeyC", "c", "C");
|
||||
this.registerEnglishKeyTextData("KeyV", "v", "V");
|
||||
this.registerEnglishKeyTextData("KeyB", "b", "B");
|
||||
this.registerEnglishKeyTextData("KeyN", "n", "N");
|
||||
this.registerEnglishKeyTextData("KeyM", "m", "M");
|
||||
}
|
||||
|
||||
registerKoreanKey() {
|
||||
this.registerKoreanKeyTextData("KeyQ", "ㅂ", "ㅃ");
|
||||
this.registerKoreanKeyTextData("KeyW", "ㅈ", "ㅉ");
|
||||
this.registerKoreanKeyTextData("KeyE", "ㄷ", "ㄸ");
|
||||
this.registerKoreanKeyTextData("KeyR", "ㄱ", "ㄲ");
|
||||
this.registerKoreanKeyTextData("KeyT", "ㅅ", "ㅆ");
|
||||
this.registerKoreanKeyTextData("KeyY", "ㅛ", "ㅛ");
|
||||
this.registerKoreanKeyTextData("KeyU", "ㅕ", "ㅕ");
|
||||
this.registerKoreanKeyTextData("KeyI", "ㅑ", "ㅑ");
|
||||
this.registerKoreanKeyTextData("KeyO", "ㅐ", "ㅒ");
|
||||
this.registerKoreanKeyTextData("KeyP", "ㅔ", "ㅖ");
|
||||
|
||||
this.registerKoreanKeyTextData("KeyA", "ㅁ", "ㅁ");
|
||||
this.registerKoreanKeyTextData("KeyS", "ㄴ", "ㄴ");
|
||||
this.registerKoreanKeyTextData("KeyD", "ㅇ", "ㅇ");
|
||||
this.registerKoreanKeyTextData("KeyF", "ㄹ", "ㄹ");
|
||||
this.registerKoreanKeyTextData("KeyG", "ㅎ", "ㅎ");
|
||||
this.registerKoreanKeyTextData("KeyH", "ㅗ", "ㅗ");
|
||||
this.registerKoreanKeyTextData("KeyJ", "ㅓ", "ㅓ");
|
||||
this.registerKoreanKeyTextData("KeyK", "ㅏ", "ㅏ");
|
||||
this.registerKoreanKeyTextData("KeyL", "ㅣ", "ㅣ");
|
||||
|
||||
this.registerKoreanKeyTextData("KeyZ", "ㅋ", "ㅋ");
|
||||
this.registerKoreanKeyTextData("KeyX", "ㅌ", "ㅌ");
|
||||
this.registerKoreanKeyTextData("KeyC", "ㅊ", "ㅊ");
|
||||
this.registerKoreanKeyTextData("KeyV", "ㅍ", "ㅍ");
|
||||
this.registerKoreanKeyTextData("KeyB", "ㅠ", "ㅠ");
|
||||
this.registerKoreanKeyTextData("KeyN", "ㅜ", "ㅜ");
|
||||
this.registerKoreanKeyTextData("KeyM", "ㅡ", "ㅡ");
|
||||
}
|
||||
|
||||
|
||||
registerFunctionKeyTextData(keyID, normalText, shiftText) {
|
||||
if(this.keyboardKeyMap[keyID] === undefined) {
|
||||
this.keyboardKeyMap[keyID] = new KeyData();
|
||||
}
|
||||
this.keyboardKeyMap[keyID].functionKey = new KeyTextData(normalText, shiftText);
|
||||
|
||||
if(this.inputKeyMap[keyID] === undefined)
|
||||
this.inputKeyMap[keyID] = keyID;
|
||||
if(this.inputKeyMap[normalText] === undefined)
|
||||
this.inputKeyMap[normalText] = keyID;
|
||||
if(this.inputKeyMap[shiftText] === undefined)
|
||||
this.inputKeyMap[shiftText] = keyID;
|
||||
}
|
||||
|
||||
registerEnglishKeyTextData(keyID, normalText, shiftText) {
|
||||
if(this.keyboardKeyMap[keyID] === undefined) {
|
||||
this.keyboardKeyMap[keyID] = new KeyData();
|
||||
}
|
||||
this.keyboardKeyMap[keyID].englishKey = new KeyTextData(normalText, shiftText);
|
||||
|
||||
if(this.inputKeyMap[keyID] === undefined)
|
||||
this.inputKeyMap[keyID] = keyID;
|
||||
if(this.inputKeyMap[normalText] === undefined)
|
||||
this.inputKeyMap[normalText] = keyID;
|
||||
if(this.inputKeyMap[shiftText] === undefined)
|
||||
this.inputKeyMap[shiftText] = keyID;
|
||||
}
|
||||
|
||||
registerKoreanKeyTextData(keyID, normalText, shiftText) {
|
||||
if(this.keyboardKeyMap[keyID] === undefined) {
|
||||
this.keyboardKeyMap[keyID] = new KeyData();
|
||||
}
|
||||
this.keyboardKeyMap[keyID].koreanKey = new KeyTextData(normalText, shiftText);
|
||||
|
||||
if(this.inputKeyMap[keyID] === undefined)
|
||||
this.inputKeyMap[keyID] = keyID;
|
||||
if(this.inputKeyMap[normalText] === undefined)
|
||||
this.inputKeyMap[normalText] = keyID;
|
||||
if(this.inputKeyMap[shiftText] === undefined)
|
||||
this.inputKeyMap[shiftText] = keyID;
|
||||
}
|
||||
|
||||
|
||||
getNormalText(keyID, language) {
|
||||
if(this.keyboardKeyMap[keyID] === undefined) {
|
||||
console.log(keyID);
|
||||
return "?";
|
||||
}
|
||||
|
||||
// console.log(keyID);
|
||||
// console.log(language);
|
||||
// console.log(this.keyboardKeyMap[keyID]);
|
||||
let keyData = this.keyboardKeyMap[keyID];
|
||||
if(language === Keyboard.ENGLISH && keyData.englishKey !== null) {
|
||||
return keyData.englishKey.normalText;
|
||||
}
|
||||
else if(language === Keyboard.KOREAN && keyData.koreanKey !== null) {
|
||||
return keyData.koreanKey.normalText;
|
||||
}
|
||||
else if(keyData.functionKey !== undefined) {
|
||||
return keyData.functionKey.normalText;
|
||||
}
|
||||
else {
|
||||
return "?";
|
||||
}
|
||||
}
|
||||
|
||||
getShiftText(keyID, language) {
|
||||
if(this.keyboardKeyMap[keyID] === undefined) {
|
||||
console.log(keyID);
|
||||
return "?";
|
||||
}
|
||||
|
||||
// console.log(keyID);
|
||||
// console.log(language);
|
||||
// console.log(this.keyboardKeyMap[keyID]);
|
||||
let keyData = this.keyboardKeyMap[keyID];
|
||||
if(language === Keyboard.ENGLISH && keyData.englishKey !== null) {
|
||||
return keyData.englishKey.shiftText;
|
||||
}
|
||||
else if(language === Keyboard.KOREAN && keyData.koreanKey !== null) {
|
||||
return keyData.koreanKey.shiftText;
|
||||
}
|
||||
else if(keyData.functionKey !== undefined) {
|
||||
return keyData.functionKey.shiftText;
|
||||
}
|
||||
else {
|
||||
return "?";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
getKeyIDOfText(text) {
|
||||
return this.inputKeyMap[text];
|
||||
}
|
||||
|
||||
isShiftText(text) {
|
||||
let keyID = this.getKeyIDOfText(text);
|
||||
let keyData = this.keyboardKeyMap[keyID];
|
||||
|
||||
if(keyData.englishKey !== null && keyData.englishKey.shiftText === text)
|
||||
return true;
|
||||
else if(keyData.koreanKey !== null && keyData.koreanKey.shiftText === text && keyData.koreanKey.normalText !== text)
|
||||
return true;
|
||||
else if(keyData.functionKey !== null && keyData.functionKey.shiftText === text)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
KeyMapper.prototype.getKeyIDOfText = function(text) {
|
||||
return this.inputKeyMap[text];
|
||||
}
|
||||
|
||||
KeyMapper.prototype.isShiftText = function(text) {
|
||||
var keyID = this.getKeyIDOfText(text);
|
||||
var keyData = this.keyboardKeyMap[keyID];
|
||||
|
||||
if(keyData.englishKey !== null && keyData.englishKey.shiftText === text)
|
||||
return true;
|
||||
else if(keyData.koreanKey !== null && keyData.koreanKey.shiftText === text && keyData.koreanKey.normalText !== text)
|
||||
return true;
|
||||
else if(keyData.functionKey !== null && keyData.functionKey.shiftText === text)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -1,421 +1,417 @@
|
||||
class Keyboard {
|
||||
function Keyboard(keyMapper, language) {
|
||||
this.keyMapper = keyMapper;
|
||||
this.language = language;
|
||||
|
||||
constructor(keyMapper, language) {
|
||||
this.keyMapper = keyMapper;
|
||||
this.language = language;
|
||||
this.keyIndex = 0;
|
||||
this.keyDataList = [];
|
||||
this.keyList = [];
|
||||
|
||||
this.keyIndex = 0;
|
||||
this.keyDataList = [];
|
||||
this.keyList = [];
|
||||
this.allKeyHash = {};
|
||||
this.normalKeyHash = {};
|
||||
|
||||
this.allKeyHash = {};
|
||||
this.normalKeyHash = {};
|
||||
this.keyUpReservations = [];
|
||||
|
||||
this.keyUpReservations = [];
|
||||
|
||||
this.highlightKey = null;
|
||||
this.highlightShiftKey = null;
|
||||
this.highlightKey = null;
|
||||
this.highlightShiftKey = null;
|
||||
|
||||
|
||||
game.input.keyboard.addCallbacks(this, this.keyDown, this.keyUp, null);
|
||||
// game.input.keyboard.processKeyDown = this.keyDown;
|
||||
// game.input.keyboard.processKeyUp = this.keyUp;
|
||||
game.input.keyboard.addCallbacks(this, this.keyDown, this.keyUp, null);
|
||||
// game.input.keyboard.processKeyDown = this.keyDown;
|
||||
// game.input.keyboard.processKeyUp = this.keyUp;
|
||||
|
||||
|
||||
let shiftKey = game.input.keyboard.addKey(Phaser.KeyCode.SHIFT);
|
||||
shiftKey.onDown.add(this.shifted, this);
|
||||
shiftKey.onUp.add(this.unshifted, this);
|
||||
var shiftKey = game.input.keyboard.addKey(Phaser.KeyCode.SHIFT);
|
||||
shiftKey.onDown.add(this.shifted, this);
|
||||
shiftKey.onUp.add(this.unshifted, this);
|
||||
|
||||
this.initKeyData();
|
||||
this.initKeyData();
|
||||
|
||||
for(let i = 0; i < this.keyDataList.length; i++) {
|
||||
this.keyList[i] = new KeyButton(
|
||||
this.keyDataList[i].x,
|
||||
this.keyDataList[i].y,
|
||||
this.keyDataList[i].width,
|
||||
this.keyDataList[i].height,
|
||||
this.keyDataList[i].normalText,
|
||||
this.keyDataList[i].shiftText,
|
||||
this.keyDataList[i].handSide,
|
||||
this.keyDataList[i].row,
|
||||
this.keyDataList[i].fingerType,
|
||||
this.keyDataList[i].alignType,
|
||||
);
|
||||
for(var i = 0; i < this.keyDataList.length; i++) {
|
||||
this.keyList[i] = new KeyButton(
|
||||
this.keyDataList[i].x,
|
||||
this.keyDataList[i].y,
|
||||
this.keyDataList[i].width,
|
||||
this.keyDataList[i].height,
|
||||
this.keyDataList[i].normalText,
|
||||
this.keyDataList[i].shiftText,
|
||||
this.keyDataList[i].handSide,
|
||||
this.keyDataList[i].row,
|
||||
this.keyDataList[i].fingerType,
|
||||
this.keyDataList[i].alignType,
|
||||
);
|
||||
|
||||
this.allKeyHash[this.keyDataList[i].keyID] = this.keyList[i];
|
||||
}
|
||||
this.allKeyHash[this.keyDataList[i].keyID] = this.keyList[i];
|
||||
}
|
||||
}
|
||||
|
||||
Keyboard.prototype.hideHighlight = function(text) {
|
||||
var keyID = this.keyMapper.getKeyIDOfText(text);
|
||||
this.allKeyHash[keyID].hideHighlight();
|
||||
|
||||
if(!this.keyMapper.isShiftText(text))
|
||||
return;
|
||||
|
||||
var handSide = this.allKeyHash[keyID].handSide;
|
||||
if(handSide === KeyButton.LEFT_HAND)
|
||||
this.allKeyHash["ShiftRight"].hideHighlight();
|
||||
else
|
||||
this.allKeyHash["ShiftLeft"].hideHighlight();
|
||||
}
|
||||
|
||||
Keyboard.prototype.showHighlight = function(text) {
|
||||
var keyID = this.keyMapper.getKeyIDOfText(text);
|
||||
var key = this.allKeyHash[keyID];
|
||||
key.showHighlight();
|
||||
}
|
||||
|
||||
Keyboard.prototype.getKeyOfText = function(text) {
|
||||
var keyID = this.keyMapper.getKeyIDOfText(text);
|
||||
return this.allKeyHash[keyID];
|
||||
}
|
||||
|
||||
Keyboard.prototype.getKey = function(keyID) {
|
||||
return this.allKeyHash[keyID];
|
||||
}
|
||||
|
||||
Keyboard.prototype.keyDown = function(char) {
|
||||
var keyCode = char.code;
|
||||
this.setPressedSprite(keyCode);
|
||||
}
|
||||
|
||||
Keyboard.prototype.setPressedSprite = function(keyCode) {
|
||||
var keyID = this.keyMapper.getKeyIDOfText(keyCode);
|
||||
var key = this.allKeyHash[keyID];
|
||||
if(key === undefined) {
|
||||
console.log(keyCode+ " is pressed but not registered to KeyMapper");
|
||||
return;
|
||||
}
|
||||
|
||||
hideHighlight(text) {
|
||||
let keyID = this.keyMapper.getKeyIDOfText(text);
|
||||
this.allKeyHash[keyID].hideHighlight();
|
||||
|
||||
if(!this.keyMapper.isShiftText(text))
|
||||
return;
|
||||
|
||||
let handSide = this.allKeyHash[keyID].handSide;
|
||||
if(handSide === KeyButton.LEFT_HAND)
|
||||
this.allKeyHash["ShiftRight"].hideHighlight();
|
||||
else
|
||||
this.allKeyHash["ShiftLeft"].hideHighlight();
|
||||
switch(keyCode) {
|
||||
case "Tab":
|
||||
case "CapsLock":
|
||||
case "MetaLeft":
|
||||
case "MetaRight":
|
||||
console.log(keyCode + " is pressed but not show");
|
||||
return;
|
||||
}
|
||||
|
||||
showHighlight(text) {
|
||||
let keyID = this.keyMapper.getKeyIDOfText(text);
|
||||
let key = this.allKeyHash[keyID];
|
||||
key.showHighlight();
|
||||
key.setTargetColor();
|
||||
}
|
||||
|
||||
Keyboard.prototype.keyUp = function(char) {
|
||||
var keyCode = char.code;
|
||||
this.setNormalSprite(keyCode);
|
||||
}
|
||||
|
||||
Keyboard.prototype.setNormalSprite = function(keyCode) {
|
||||
var keyID = this.keyMapper.getKeyIDOfText(keyCode);
|
||||
var key = this.allKeyHash[keyID];
|
||||
if(key !== undefined)
|
||||
key.setNormalColor();
|
||||
}
|
||||
|
||||
|
||||
|
||||
Keyboard.prototype.shifted = function() {
|
||||
for(var i = 0; i < this.keyDataList.length; i++) {
|
||||
this.keyList[i].onShiftPressed();
|
||||
}
|
||||
}
|
||||
|
||||
getKeyOfText(text) {
|
||||
let keyID = this.keyMapper.getKeyIDOfText(text);
|
||||
return this.allKeyHash[keyID];
|
||||
Keyboard.prototype.unshifted = function() {
|
||||
for(var i = 0; i < this.keyDataList.length; i++) {
|
||||
this.keyList[i].onShiftUnpressed();
|
||||
}
|
||||
}
|
||||
|
||||
getKey(keyID) {
|
||||
return this.allKeyHash[keyID];
|
||||
}
|
||||
|
||||
keyDown(char) {
|
||||
let keyCode = char.code;
|
||||
this.setPressedSprite(keyCode);
|
||||
}
|
||||
Keyboard.prototype.keyPress = function(char) {
|
||||
// self.checkTypingContents(event);
|
||||
// console.log(char);
|
||||
if(game.input.keyboard.isDown(Phaser.Keyboard.SHIFT))
|
||||
console.log("shift is pressed");
|
||||
}
|
||||
|
||||
setPressedSprite(keyCode) {
|
||||
let keyID = this.keyMapper.getKeyIDOfText(keyCode);
|
||||
let key = this.allKeyHash[keyID];
|
||||
if(key === undefined) {
|
||||
console.log(keyCode+ " is pressed but not registered to KeyMapper");
|
||||
return;
|
||||
}
|
||||
|
||||
switch(keyCode) {
|
||||
case "Tab":
|
||||
case "CapsLock":
|
||||
case "MetaLeft":
|
||||
case "MetaRight":
|
||||
console.log(keyCode + " is pressed but not show");
|
||||
return;
|
||||
}
|
||||
Keyboard.prototype.makeKeyDataObject = function(keyID, normalText, shiftText, handSide, row, fingerType, x, y, width, height, alignType) {
|
||||
var keyDataObject = {};
|
||||
keyDataObject.keyID = keyID;
|
||||
keyDataObject.normalText = normalText;
|
||||
keyDataObject.shiftText = shiftText;
|
||||
keyDataObject.handSide = handSide;
|
||||
keyDataObject.row = row;
|
||||
keyDataObject.fingerType = fingerType;
|
||||
keyDataObject.x = x;
|
||||
keyDataObject.y = y;
|
||||
keyDataObject.width = width;
|
||||
keyDataObject.height = height;
|
||||
keyDataObject.alignType = alignType;
|
||||
|
||||
key.setTargetColor();
|
||||
}
|
||||
return keyDataObject;
|
||||
}
|
||||
|
||||
keyUp(char) {
|
||||
let keyCode = char.code;
|
||||
this.setNormalSprite(keyCode);
|
||||
}
|
||||
Keyboard.prototype.makeNextNormalKeyDataObject = function(keyID, prevKeyData, normalText, shiftText, handSide, fingerType) {
|
||||
return this.makeKeyDataObject(
|
||||
keyID,
|
||||
normalText,
|
||||
shiftText,
|
||||
handSide,
|
||||
prevKeyData.row,
|
||||
fingerType,
|
||||
prevKeyData.x + prevKeyData.width + Keyboard.KEY_GAP_PX,
|
||||
prevKeyData.y,
|
||||
Keyboard.DEFAULT_KEY_SIZE_PX,
|
||||
Keyboard.DEFAULT_KEY_SIZE_PX,
|
||||
KeyButton.NORMAL_KEY
|
||||
);
|
||||
}
|
||||
|
||||
setNormalSprite(keyCode) {
|
||||
let keyID = this.keyMapper.getKeyIDOfText(keyCode);
|
||||
let key = this.allKeyHash[keyID];
|
||||
if(key !== undefined)
|
||||
key.setNormalColor();
|
||||
}
|
||||
|
||||
Keyboard.prototype.addFunctionKeyData = function(keyID, handSide, row, fingerType, x, y, width, height, type) {
|
||||
var normalText = this.keyMapper.getNormalText(keyID, this.language);
|
||||
var shiftText = this.keyMapper.getShiftText(keyID, this.language);
|
||||
|
||||
var newKey = this.makeKeyDataObject(
|
||||
keyID,
|
||||
normalText, shiftText,
|
||||
handSide, row, fingerType,
|
||||
x, y,
|
||||
width, height,
|
||||
type
|
||||
);
|
||||
this.keyDataList[this.keyIndex] = newKey;
|
||||
this.keyIndex++;
|
||||
}
|
||||
|
||||
Keyboard.prototype.addNextFunctionKeyData = function(keyID, handSide, fingerType, width, height, type) {
|
||||
var prevKey = this.keyDataList[this.keyIndex - 1];
|
||||
var normalText = this.keyMapper.getNormalText(keyID, this.language);
|
||||
var shiftText = this.keyMapper.getShiftText(keyID, this.language);
|
||||
|
||||
var newKey = this.makeKeyDataObject(
|
||||
keyID,
|
||||
normalText, shiftText,
|
||||
handSide, prevKey.row, fingerType,
|
||||
prevKey.x + prevKey.width + Keyboard.KEY_GAP_PX, prevKey.y,
|
||||
width, height,
|
||||
type
|
||||
);
|
||||
this.keyDataList[this.keyIndex] = newKey;
|
||||
this.keyIndex++;
|
||||
|
||||
// this.normalKeyHash[keyID] = newKey;
|
||||
}
|
||||
|
||||
Keyboard.prototype.addNextNormalKeyData = function(keyID, handSide, fingerType) {
|
||||
var prevKey = this.keyDataList[this.keyIndex - 1];
|
||||
var normalText = this.keyMapper.getNormalText(keyID, this.language);
|
||||
var shiftText = this.keyMapper.getShiftText(keyID, this.language);
|
||||
|
||||
var newKey = this.makeNextNormalKeyDataObject(
|
||||
keyID,
|
||||
prevKey,
|
||||
normalText, shiftText,
|
||||
handSide, fingerType
|
||||
);
|
||||
this.keyDataList[this.keyIndex] = newKey;
|
||||
this.keyIndex++;
|
||||
|
||||
this.normalKeyHash[keyID] = newKey;
|
||||
}
|
||||
|
||||
|
||||
|
||||
shifted() {
|
||||
for(let i = 0; i < this.keyDataList.length; i++) {
|
||||
this.keyList[i].onShiftPressed();
|
||||
}
|
||||
}
|
||||
Keyboard.prototype.initKeyData = function(keyMapper) {
|
||||
// row 1
|
||||
this.addFunctionKeyData(
|
||||
"Backquote",
|
||||
KeyButton.LEFT_HAND,
|
||||
Keyboard.ROW_1,
|
||||
KeyButton.LITTLE_FINGER,
|
||||
Keyboard.KEYBOARD_OFFSET_POX_X,
|
||||
Keyboard.ROW_1_POX_Y,
|
||||
Keyboard.DEFAULT_KEY_SIZE_PX,
|
||||
Keyboard.DEFAULT_KEY_SIZE_PX,
|
||||
KeyButton.NORMAL_FUNCTION_KEY
|
||||
);
|
||||
this.addNextNormalKeyData("Digit1", KeyButton.LEFT_HAND, KeyButton.LITTLE_FINGER);
|
||||
this.addNextNormalKeyData("Digit2", KeyButton.LEFT_HAND, KeyButton.RING_FINGER);
|
||||
this.addNextNormalKeyData("Digit3", KeyButton.LEFT_HAND, KeyButton.MIDDLE_FINGER);
|
||||
this.addNextNormalKeyData("Digit4", KeyButton.LEFT_HAND, KeyButton.INDEX_FINGER);
|
||||
this.addNextNormalKeyData("Digit5", KeyButton.LEFT_HAND, KeyButton.INDEX_FINGER);
|
||||
this.addNextNormalKeyData("Digit6", KeyButton.RIGHT_HAND, KeyButton.INDEX_FINGER);
|
||||
this.addNextNormalKeyData("Digit7", KeyButton.RIGHT_HAND, KeyButton.INDEX_FINGER);
|
||||
this.addNextNormalKeyData("Digit8", KeyButton.RIGHT_HAND, KeyButton.MIDDLE_FINGER);
|
||||
this.addNextNormalKeyData("Digit9", KeyButton.RIGHT_HAND, KeyButton.RING_FINGER);
|
||||
this.addNextNormalKeyData("Digit0", KeyButton.RIGHT_HAND, KeyButton.LITTLE_FINGER);
|
||||
this.addNextNormalKeyData("Minus", KeyButton.RIGHT_HAND, KeyButton.LITTLE_FINGER);
|
||||
this.addNextNormalKeyData("Equal", KeyButton.RIGHT_HAND, KeyButton.LITTLE_FINGER);
|
||||
this.addNextFunctionKeyData(
|
||||
"Backspace",
|
||||
KeyButton.RIGHT_HAND,
|
||||
KeyButton.LITTLE_FINGER,
|
||||
Keyboard.BACKSPACE_KEY_WIDTH_PX,
|
||||
Keyboard.DEFAULT_KEY_SIZE_PX,
|
||||
KeyButton.RIGHT_FUNCTION_KEY
|
||||
);
|
||||
|
||||
unshifted() {
|
||||
for(let i = 0; i < this.keyDataList.length; i++) {
|
||||
this.keyList[i].onShiftUnpressed();
|
||||
}
|
||||
}
|
||||
// row 2
|
||||
this.addFunctionKeyData(
|
||||
"Tab",
|
||||
KeyButton.LEFT_HAND,
|
||||
Keyboard.ROW_2,
|
||||
KeyButton.NONE_FINGER,
|
||||
Keyboard.KEYBOARD_OFFSET_POX_X,
|
||||
Keyboard.ROW_2_POX_Y,
|
||||
Keyboard.TAB_KEY_WIDTH_PX,
|
||||
Keyboard.DEFAULT_KEY_SIZE_PX,
|
||||
KeyButton.LEFT_FUNCTION_KEY
|
||||
);
|
||||
this.addNextNormalKeyData("KeyQ", KeyButton.LEFT_HAND, KeyButton.LITTLE_FINGER);
|
||||
this.addNextNormalKeyData("KeyW", KeyButton.LEFT_HAND, KeyButton.RING_FINGER);
|
||||
this.addNextNormalKeyData("KeyE", KeyButton.LEFT_HAND, KeyButton.MIDDLE_FINGER);
|
||||
this.addNextNormalKeyData("KeyR", KeyButton.LEFT_HAND, KeyButton.INDEX_FINGER);
|
||||
this.addNextNormalKeyData("KeyT", KeyButton.LEFT_HAND, KeyButton.INDEX_FINGER);
|
||||
this.addNextNormalKeyData("KeyY", KeyButton.RIGHT_HAND, KeyButton.INDEX_FINGER);
|
||||
this.addNextNormalKeyData("KeyU", KeyButton.RIGHT_HAND, KeyButton.INDEX_FINGER);
|
||||
this.addNextNormalKeyData("KeyI", KeyButton.RIGHT_HAND, KeyButton.MIDDLE_FINGER);
|
||||
this.addNextNormalKeyData("KeyO", KeyButton.RIGHT_HAND, KeyButton.RING_FINGER);
|
||||
this.addNextNormalKeyData("KeyP", KeyButton.RIGHT_HAND, KeyButton.LITTLE_FINGER);
|
||||
this.addNextNormalKeyData("BracketLeft", KeyButton.RIGHT_HAND, KeyButton.LITTLE_FINGER);
|
||||
this.addNextNormalKeyData("BracketRight", KeyButton.RIGHT_HAND, KeyButton.LITTLE_FINGER);
|
||||
this.addNextNormalKeyData("Backslash", KeyButton.RIGHT_HAND, KeyButton.LITTLE_FINGER);
|
||||
|
||||
// row 3
|
||||
this.addFunctionKeyData(
|
||||
"CapsLock",
|
||||
KeyButton.LEFT_HAND,
|
||||
Keyboard.ROW_3,
|
||||
KeyButton.NONE_FINGER,
|
||||
Keyboard.KEYBOARD_OFFSET_POX_X,
|
||||
Keyboard.ROW_3_POX_Y,
|
||||
Keyboard.CAPS_LOCK_KEY_WIDTH_PX,
|
||||
Keyboard.DEFAULT_KEY_SIZE_PX,
|
||||
KeyButton.LEFT_FUNCTION_KEY
|
||||
);
|
||||
this.addNextNormalKeyData("KeyA", KeyButton.LEFT_HAND, KeyButton.LITTLE_FINGER);
|
||||
this.addNextNormalKeyData("KeyS", KeyButton.LEFT_HAND, KeyButton.RING_FINGER);
|
||||
this.addNextNormalKeyData("KeyD", KeyButton.LEFT_HAND, KeyButton.MIDDLE_FINGER);
|
||||
this.addNextNormalKeyData("KeyF", KeyButton.LEFT_HAND, KeyButton.INDEX_FINGER_BASELINE);
|
||||
this.addNextNormalKeyData("KeyG", KeyButton.LEFT_HAND, KeyButton.INDEX_FINGER);
|
||||
this.addNextNormalKeyData("KeyH", KeyButton.RIGHT_HAND, KeyButton.INDEX_FINGER);
|
||||
this.addNextNormalKeyData("KeyJ", KeyButton.RIGHT_HAND, KeyButton.INDEX_FINGER_BASELINE);
|
||||
this.addNextNormalKeyData("KeyK", KeyButton.RIGHT_HAND, KeyButton.MIDDLE_FINGER);
|
||||
this.addNextNormalKeyData("KeyL", KeyButton.RIGHT_HAND, KeyButton.RING_FINGER);
|
||||
this.addNextNormalKeyData("Semicolon", KeyButton.RIGHT_HAND, KeyButton.LITTLE_FINGER);
|
||||
this.addNextNormalKeyData("Quote", KeyButton.RIGHT_HAND, KeyButton.LITTLE_FINGER);
|
||||
this.addNextFunctionKeyData(
|
||||
"Enter",
|
||||
KeyButton.RIGHT_HAND,
|
||||
KeyButton.LITTLE_FINGER,
|
||||
Keyboard.ENTER_KEY_WIDTH_PX,
|
||||
Keyboard.DEFAULT_KEY_SIZE_PX,
|
||||
KeyButton.RIGHT_FUNCTION_KEY
|
||||
);
|
||||
|
||||
keyPress(char) {
|
||||
// self.checkTypingContents(event);
|
||||
// console.log(char);
|
||||
if(game.input.keyboard.isDown(Phaser.Keyboard.SHIFT))
|
||||
console.log("shift is pressed");
|
||||
}
|
||||
|
||||
|
||||
makeKeyDataObject(keyID, normalText, shiftText, handSide, row, fingerType, x, y, width, height, alignType) {
|
||||
let keyDataObject = {};
|
||||
keyDataObject.keyID = keyID;
|
||||
keyDataObject.normalText = normalText;
|
||||
keyDataObject.shiftText = shiftText;
|
||||
keyDataObject.handSide = handSide;
|
||||
keyDataObject.row = row;
|
||||
keyDataObject.fingerType = fingerType;
|
||||
keyDataObject.x = x;
|
||||
keyDataObject.y = y;
|
||||
keyDataObject.width = width;
|
||||
keyDataObject.height = height;
|
||||
keyDataObject.alignType = alignType;
|
||||
|
||||
return keyDataObject;
|
||||
}
|
||||
|
||||
makeNextNormalKeyDataObject(keyID, prevKeyData, normalText, shiftText, handSide, fingerType) {
|
||||
return this.makeKeyDataObject(
|
||||
keyID,
|
||||
normalText,
|
||||
shiftText,
|
||||
handSide,
|
||||
prevKeyData.row,
|
||||
fingerType,
|
||||
prevKeyData.x + prevKeyData.width + Keyboard.KEY_GAP_PX,
|
||||
prevKeyData.y,
|
||||
Keyboard.DEFAULT_KEY_SIZE_PX,
|
||||
Keyboard.DEFAULT_KEY_SIZE_PX,
|
||||
KeyButton.NORMAL_KEY
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
addFunctionKeyData(keyID, handSide, row, fingerType, x, y, width, height, type) {
|
||||
let normalText = this.keyMapper.getNormalText(keyID, this.language);
|
||||
let shiftText = this.keyMapper.getShiftText(keyID, this.language);
|
||||
|
||||
let newKey = this.makeKeyDataObject(
|
||||
keyID,
|
||||
normalText, shiftText,
|
||||
handSide, row, fingerType,
|
||||
x, y,
|
||||
width, height,
|
||||
type
|
||||
);
|
||||
this.keyDataList[this.keyIndex] = newKey;
|
||||
this.keyIndex++;
|
||||
}
|
||||
|
||||
addNextFunctionKeyData(keyID, handSide, fingerType, width, height, type) {
|
||||
let prevKey = this.keyDataList[this.keyIndex - 1];
|
||||
let normalText = this.keyMapper.getNormalText(keyID, this.language);
|
||||
let shiftText = this.keyMapper.getShiftText(keyID, this.language);
|
||||
|
||||
let newKey = this.makeKeyDataObject(
|
||||
keyID,
|
||||
normalText, shiftText,
|
||||
handSide, prevKey.row, fingerType,
|
||||
prevKey.x + prevKey.width + Keyboard.KEY_GAP_PX, prevKey.y,
|
||||
width, height,
|
||||
type
|
||||
);
|
||||
this.keyDataList[this.keyIndex] = newKey;
|
||||
this.keyIndex++;
|
||||
|
||||
// this.normalKeyHash[keyID] = newKey;
|
||||
}
|
||||
|
||||
addNextNormalKeyData(keyID, handSide, fingerType) {
|
||||
let prevKey = this.keyDataList[this.keyIndex - 1];
|
||||
let normalText = this.keyMapper.getNormalText(keyID, this.language);
|
||||
let shiftText = this.keyMapper.getShiftText(keyID, this.language);
|
||||
|
||||
let newKey = this.makeNextNormalKeyDataObject(
|
||||
keyID,
|
||||
prevKey,
|
||||
normalText, shiftText,
|
||||
handSide, fingerType
|
||||
);
|
||||
this.keyDataList[this.keyIndex] = newKey;
|
||||
this.keyIndex++;
|
||||
|
||||
this.normalKeyHash[keyID] = newKey;
|
||||
}
|
||||
|
||||
|
||||
|
||||
initKeyData(keyMapper) {
|
||||
// row 1
|
||||
this.addFunctionKeyData(
|
||||
"Backquote",
|
||||
KeyButton.LEFT_HAND,
|
||||
Keyboard.ROW_1,
|
||||
KeyButton.LITTLE_FINGER,
|
||||
Keyboard.KEYBOARD_OFFSET_POX_X,
|
||||
Keyboard.ROW_1_POX_Y,
|
||||
Keyboard.DEFAULT_KEY_SIZE_PX,
|
||||
Keyboard.DEFAULT_KEY_SIZE_PX,
|
||||
KeyButton.NORMAL_FUNCTION_KEY
|
||||
);
|
||||
this.addNextNormalKeyData("Digit1", KeyButton.LEFT_HAND, KeyButton.LITTLE_FINGER);
|
||||
this.addNextNormalKeyData("Digit2", KeyButton.LEFT_HAND, KeyButton.RING_FINGER);
|
||||
this.addNextNormalKeyData("Digit3", KeyButton.LEFT_HAND, KeyButton.MIDDLE_FINGER);
|
||||
this.addNextNormalKeyData("Digit4", KeyButton.LEFT_HAND, KeyButton.INDEX_FINGER);
|
||||
this.addNextNormalKeyData("Digit5", KeyButton.LEFT_HAND, KeyButton.INDEX_FINGER);
|
||||
this.addNextNormalKeyData("Digit6", KeyButton.RIGHT_HAND, KeyButton.INDEX_FINGER);
|
||||
this.addNextNormalKeyData("Digit7", KeyButton.RIGHT_HAND, KeyButton.INDEX_FINGER);
|
||||
this.addNextNormalKeyData("Digit8", KeyButton.RIGHT_HAND, KeyButton.MIDDLE_FINGER);
|
||||
this.addNextNormalKeyData("Digit9", KeyButton.RIGHT_HAND, KeyButton.RING_FINGER);
|
||||
this.addNextNormalKeyData("Digit0", KeyButton.RIGHT_HAND, KeyButton.LITTLE_FINGER);
|
||||
this.addNextNormalKeyData("Minus", KeyButton.RIGHT_HAND, KeyButton.LITTLE_FINGER);
|
||||
this.addNextNormalKeyData("Equal", KeyButton.RIGHT_HAND, KeyButton.LITTLE_FINGER);
|
||||
this.addNextFunctionKeyData(
|
||||
"Backspace",
|
||||
KeyButton.RIGHT_HAND,
|
||||
KeyButton.LITTLE_FINGER,
|
||||
Keyboard.BACKSPACE_KEY_WIDTH_PX,
|
||||
Keyboard.DEFAULT_KEY_SIZE_PX,
|
||||
KeyButton.RIGHT_FUNCTION_KEY
|
||||
);
|
||||
|
||||
// row 2
|
||||
this.addFunctionKeyData(
|
||||
"Tab",
|
||||
KeyButton.LEFT_HAND,
|
||||
Keyboard.ROW_2,
|
||||
KeyButton.NONE_FINGER,
|
||||
Keyboard.KEYBOARD_OFFSET_POX_X,
|
||||
Keyboard.ROW_2_POX_Y,
|
||||
Keyboard.TAB_KEY_WIDTH_PX,
|
||||
Keyboard.DEFAULT_KEY_SIZE_PX,
|
||||
KeyButton.LEFT_FUNCTION_KEY
|
||||
);
|
||||
this.addNextNormalKeyData("KeyQ", KeyButton.LEFT_HAND, KeyButton.LITTLE_FINGER);
|
||||
this.addNextNormalKeyData("KeyW", KeyButton.LEFT_HAND, KeyButton.RING_FINGER);
|
||||
this.addNextNormalKeyData("KeyE", KeyButton.LEFT_HAND, KeyButton.MIDDLE_FINGER);
|
||||
this.addNextNormalKeyData("KeyR", KeyButton.LEFT_HAND, KeyButton.INDEX_FINGER);
|
||||
this.addNextNormalKeyData("KeyT", KeyButton.LEFT_HAND, KeyButton.INDEX_FINGER);
|
||||
this.addNextNormalKeyData("KeyY", KeyButton.RIGHT_HAND, KeyButton.INDEX_FINGER);
|
||||
this.addNextNormalKeyData("KeyU", KeyButton.RIGHT_HAND, KeyButton.INDEX_FINGER);
|
||||
this.addNextNormalKeyData("KeyI", KeyButton.RIGHT_HAND, KeyButton.MIDDLE_FINGER);
|
||||
this.addNextNormalKeyData("KeyO", KeyButton.RIGHT_HAND, KeyButton.RING_FINGER);
|
||||
this.addNextNormalKeyData("KeyP", KeyButton.RIGHT_HAND, KeyButton.LITTLE_FINGER);
|
||||
this.addNextNormalKeyData("BracketLeft", KeyButton.RIGHT_HAND, KeyButton.LITTLE_FINGER);
|
||||
this.addNextNormalKeyData("BracketRight", KeyButton.RIGHT_HAND, KeyButton.LITTLE_FINGER);
|
||||
this.addNextNormalKeyData("Backslash", KeyButton.RIGHT_HAND, KeyButton.LITTLE_FINGER);
|
||||
|
||||
// row 3
|
||||
this.addFunctionKeyData(
|
||||
"CapsLock",
|
||||
KeyButton.LEFT_HAND,
|
||||
Keyboard.ROW_3,
|
||||
KeyButton.NONE_FINGER,
|
||||
Keyboard.KEYBOARD_OFFSET_POX_X,
|
||||
Keyboard.ROW_3_POX_Y,
|
||||
Keyboard.CAPS_LOCK_KEY_WIDTH_PX,
|
||||
Keyboard.DEFAULT_KEY_SIZE_PX,
|
||||
KeyButton.LEFT_FUNCTION_KEY
|
||||
);
|
||||
this.addNextNormalKeyData("KeyA", KeyButton.LEFT_HAND, KeyButton.LITTLE_FINGER);
|
||||
this.addNextNormalKeyData("KeyS", KeyButton.LEFT_HAND, KeyButton.RING_FINGER);
|
||||
this.addNextNormalKeyData("KeyD", KeyButton.LEFT_HAND, KeyButton.MIDDLE_FINGER);
|
||||
this.addNextNormalKeyData("KeyF", KeyButton.LEFT_HAND, KeyButton.INDEX_FINGER_BASELINE);
|
||||
this.addNextNormalKeyData("KeyG", KeyButton.LEFT_HAND, KeyButton.INDEX_FINGER);
|
||||
this.addNextNormalKeyData("KeyH", KeyButton.RIGHT_HAND, KeyButton.INDEX_FINGER);
|
||||
this.addNextNormalKeyData("KeyJ", KeyButton.RIGHT_HAND, KeyButton.INDEX_FINGER_BASELINE);
|
||||
this.addNextNormalKeyData("KeyK", KeyButton.RIGHT_HAND, KeyButton.MIDDLE_FINGER);
|
||||
this.addNextNormalKeyData("KeyL", KeyButton.RIGHT_HAND, KeyButton.RING_FINGER);
|
||||
this.addNextNormalKeyData("Semicolon", KeyButton.RIGHT_HAND, KeyButton.LITTLE_FINGER);
|
||||
this.addNextNormalKeyData("Quote", KeyButton.RIGHT_HAND, KeyButton.LITTLE_FINGER);
|
||||
this.addNextFunctionKeyData(
|
||||
"Enter",
|
||||
KeyButton.RIGHT_HAND,
|
||||
KeyButton.LITTLE_FINGER,
|
||||
Keyboard.ENTER_KEY_WIDTH_PX,
|
||||
Keyboard.DEFAULT_KEY_SIZE_PX,
|
||||
KeyButton.RIGHT_FUNCTION_KEY
|
||||
);
|
||||
|
||||
// row 4
|
||||
this.addFunctionKeyData(
|
||||
"ShiftLeft",
|
||||
KeyButton.LEFT_HAND,
|
||||
Keyboard.ROW_4,
|
||||
KeyButton.LITTLE_FINGER,
|
||||
Keyboard.KEYBOARD_OFFSET_POX_X,
|
||||
Keyboard.ROW_4_POX_Y,
|
||||
Keyboard.SHIFT_KEY_WIDTH_PX,
|
||||
Keyboard.DEFAULT_KEY_SIZE_PX,
|
||||
KeyButton.LEFT_FUNCTION_KEY
|
||||
);
|
||||
this.addNextNormalKeyData("KeyZ", KeyButton.LEFT_HAND, KeyButton.LITTLE_FINGER);
|
||||
this.addNextNormalKeyData("KeyX", KeyButton.LEFT_HAND, KeyButton.RING_FINGER);
|
||||
this.addNextNormalKeyData("KeyC", KeyButton.LEFT_HAND, KeyButton.MIDDLE_FINGER);
|
||||
this.addNextNormalKeyData("KeyV", KeyButton.LEFT_HAND, KeyButton.INDEX_FINGER);
|
||||
this.addNextNormalKeyData("KeyB", KeyButton.LEFT_HAND, KeyButton.INDEX_FINGER);
|
||||
this.addNextNormalKeyData("KeyN", KeyButton.RIGHT_HAND, KeyButton.INDEX_FINGER);
|
||||
this.addNextNormalKeyData("KeyM", KeyButton.RIGHT_HAND, KeyButton.INDEX_FINGER);
|
||||
this.addNextNormalKeyData("Comma", KeyButton.RIGHT_HAND, KeyButton.MIDDLE_FINGER);
|
||||
this.addNextNormalKeyData("Period", KeyButton.RIGHT_HAND, KeyButton.RING_FINGER);
|
||||
this.addNextNormalKeyData("Slash", KeyButton.RIGHT_HAND, KeyButton.LITTLE_FINGER);
|
||||
this.addNextFunctionKeyData(
|
||||
"ShiftRight",
|
||||
KeyButton.RIGHT_HAND,
|
||||
KeyButton.LITTLE_FINGER,
|
||||
Keyboard.SHIFT_KEY_WIDTH_PX,
|
||||
Keyboard.DEFAULT_KEY_SIZE_PX,
|
||||
KeyButton.RIGHT_FUNCTION_KEY
|
||||
);
|
||||
|
||||
// row 5
|
||||
this.addFunctionKeyData(
|
||||
"ControlLeft",
|
||||
KeyButton.LEFT_HAND,
|
||||
Keyboard.ROW_5,
|
||||
KeyButton.NONE_FINGER,
|
||||
Keyboard.KEYBOARD_OFFSET_POX_X,
|
||||
Keyboard.ROW_5_POX_Y,
|
||||
Keyboard.CTRL_KEY_WIDTH_PX,
|
||||
Keyboard.DEFAULT_KEY_SIZE_PX,
|
||||
KeyButton.LEFT_FUNCTION_KEY
|
||||
);
|
||||
this.addNextFunctionKeyData(
|
||||
"window",
|
||||
KeyButton.LEFT_HAND,
|
||||
KeyButton.NONE_FINGER,
|
||||
Keyboard.WINDOW_KEY_WIDTH_PX,
|
||||
Keyboard.DEFAULT_KEY_SIZE_PX,
|
||||
KeyButton.LEFT_FUNCTION_KEY
|
||||
);
|
||||
this.addNextFunctionKeyData(
|
||||
"AltLeft",
|
||||
KeyButton.LEFT_HAND,
|
||||
KeyButton.NONE_FINGER,
|
||||
Keyboard.ALT_KEY_WIDTH_PX,
|
||||
Keyboard.DEFAULT_KEY_SIZE_PX,
|
||||
KeyButton.LEFT_FUNCTION_KEY
|
||||
);
|
||||
this.addNextFunctionKeyData(
|
||||
"Chinese",
|
||||
KeyButton.LEFT_HAND,
|
||||
KeyButton.NONE_FINGER,
|
||||
Keyboard.CHINESE_KEY_WIDTH_PX,
|
||||
Keyboard.DEFAULT_KEY_SIZE_PX,
|
||||
KeyButton.LEFT_FUNCTION_KEY
|
||||
);
|
||||
this.addNextFunctionKeyData(
|
||||
"Space",
|
||||
KeyButton.BOTH_HAND,
|
||||
KeyButton.THUMB,
|
||||
Keyboard.SPACE_KEY_WIDTH_PX,
|
||||
Keyboard.DEFAULT_KEY_SIZE_PX,
|
||||
KeyButton.CENTER_FUNCTION_KEY
|
||||
);
|
||||
this.addNextFunctionKeyData(
|
||||
"KoreanEnglish",
|
||||
KeyButton.RIGHT_HAND,
|
||||
KeyButton.NONE_FINGER,
|
||||
Keyboard.KOREAN_ENGLISH_KEY_WIDTH_PX,
|
||||
Keyboard.DEFAULT_KEY_SIZE_PX,
|
||||
KeyButton.RIGHT_FUNCTION_KEY
|
||||
);
|
||||
this.addNextFunctionKeyData(
|
||||
"AltRight",
|
||||
KeyButton.RIGHT_HAND,
|
||||
KeyButton.NONE_FINGER,
|
||||
Keyboard.ALT_KEY_WIDTH_PX,
|
||||
Keyboard.DEFAULT_KEY_SIZE_PX,
|
||||
KeyButton.RIGHT_FUNCTION_KEY
|
||||
);
|
||||
this.addNextFunctionKeyData(
|
||||
"ControlRight",
|
||||
KeyButton.RIGHT_HAND,
|
||||
KeyButton.NONE_FINGER,
|
||||
Keyboard.CTRL_KEY_WIDTH_PX,
|
||||
Keyboard.DEFAULT_KEY_SIZE_PX,
|
||||
KeyButton.RIGHT_FUNCTION_KEY
|
||||
);
|
||||
}
|
||||
// row 4
|
||||
this.addFunctionKeyData(
|
||||
"ShiftLeft",
|
||||
KeyButton.LEFT_HAND,
|
||||
Keyboard.ROW_4,
|
||||
KeyButton.LITTLE_FINGER,
|
||||
Keyboard.KEYBOARD_OFFSET_POX_X,
|
||||
Keyboard.ROW_4_POX_Y,
|
||||
Keyboard.SHIFT_KEY_WIDTH_PX,
|
||||
Keyboard.DEFAULT_KEY_SIZE_PX,
|
||||
KeyButton.LEFT_FUNCTION_KEY
|
||||
);
|
||||
this.addNextNormalKeyData("KeyZ", KeyButton.LEFT_HAND, KeyButton.LITTLE_FINGER);
|
||||
this.addNextNormalKeyData("KeyX", KeyButton.LEFT_HAND, KeyButton.RING_FINGER);
|
||||
this.addNextNormalKeyData("KeyC", KeyButton.LEFT_HAND, KeyButton.MIDDLE_FINGER);
|
||||
this.addNextNormalKeyData("KeyV", KeyButton.LEFT_HAND, KeyButton.INDEX_FINGER);
|
||||
this.addNextNormalKeyData("KeyB", KeyButton.LEFT_HAND, KeyButton.INDEX_FINGER);
|
||||
this.addNextNormalKeyData("KeyN", KeyButton.RIGHT_HAND, KeyButton.INDEX_FINGER);
|
||||
this.addNextNormalKeyData("KeyM", KeyButton.RIGHT_HAND, KeyButton.INDEX_FINGER);
|
||||
this.addNextNormalKeyData("Comma", KeyButton.RIGHT_HAND, KeyButton.MIDDLE_FINGER);
|
||||
this.addNextNormalKeyData("Period", KeyButton.RIGHT_HAND, KeyButton.RING_FINGER);
|
||||
this.addNextNormalKeyData("Slash", KeyButton.RIGHT_HAND, KeyButton.LITTLE_FINGER);
|
||||
this.addNextFunctionKeyData(
|
||||
"ShiftRight",
|
||||
KeyButton.RIGHT_HAND,
|
||||
KeyButton.LITTLE_FINGER,
|
||||
Keyboard.SHIFT_KEY_WIDTH_PX,
|
||||
Keyboard.DEFAULT_KEY_SIZE_PX,
|
||||
KeyButton.RIGHT_FUNCTION_KEY
|
||||
);
|
||||
|
||||
// row 5
|
||||
this.addFunctionKeyData(
|
||||
"ControlLeft",
|
||||
KeyButton.LEFT_HAND,
|
||||
Keyboard.ROW_5,
|
||||
KeyButton.NONE_FINGER,
|
||||
Keyboard.KEYBOARD_OFFSET_POX_X,
|
||||
Keyboard.ROW_5_POX_Y,
|
||||
Keyboard.CTRL_KEY_WIDTH_PX,
|
||||
Keyboard.DEFAULT_KEY_SIZE_PX,
|
||||
KeyButton.LEFT_FUNCTION_KEY
|
||||
);
|
||||
this.addNextFunctionKeyData(
|
||||
"window",
|
||||
KeyButton.LEFT_HAND,
|
||||
KeyButton.NONE_FINGER,
|
||||
Keyboard.WINDOW_KEY_WIDTH_PX,
|
||||
Keyboard.DEFAULT_KEY_SIZE_PX,
|
||||
KeyButton.LEFT_FUNCTION_KEY
|
||||
);
|
||||
this.addNextFunctionKeyData(
|
||||
"AltLeft",
|
||||
KeyButton.LEFT_HAND,
|
||||
KeyButton.NONE_FINGER,
|
||||
Keyboard.ALT_KEY_WIDTH_PX,
|
||||
Keyboard.DEFAULT_KEY_SIZE_PX,
|
||||
KeyButton.LEFT_FUNCTION_KEY
|
||||
);
|
||||
this.addNextFunctionKeyData(
|
||||
"Chinese",
|
||||
KeyButton.LEFT_HAND,
|
||||
KeyButton.NONE_FINGER,
|
||||
Keyboard.CHINESE_KEY_WIDTH_PX,
|
||||
Keyboard.DEFAULT_KEY_SIZE_PX,
|
||||
KeyButton.LEFT_FUNCTION_KEY
|
||||
);
|
||||
this.addNextFunctionKeyData(
|
||||
"Space",
|
||||
KeyButton.BOTH_HAND,
|
||||
KeyButton.THUMB,
|
||||
Keyboard.SPACE_KEY_WIDTH_PX,
|
||||
Keyboard.DEFAULT_KEY_SIZE_PX,
|
||||
KeyButton.CENTER_FUNCTION_KEY
|
||||
);
|
||||
this.addNextFunctionKeyData(
|
||||
"KoreanEnglish",
|
||||
KeyButton.RIGHT_HAND,
|
||||
KeyButton.NONE_FINGER,
|
||||
Keyboard.KOREAN_ENGLISH_KEY_WIDTH_PX,
|
||||
Keyboard.DEFAULT_KEY_SIZE_PX,
|
||||
KeyButton.RIGHT_FUNCTION_KEY
|
||||
);
|
||||
this.addNextFunctionKeyData(
|
||||
"AltRight",
|
||||
KeyButton.RIGHT_HAND,
|
||||
KeyButton.NONE_FINGER,
|
||||
Keyboard.ALT_KEY_WIDTH_PX,
|
||||
Keyboard.DEFAULT_KEY_SIZE_PX,
|
||||
KeyButton.RIGHT_FUNCTION_KEY
|
||||
);
|
||||
this.addNextFunctionKeyData(
|
||||
"ControlRight",
|
||||
KeyButton.RIGHT_HAND,
|
||||
KeyButton.NONE_FINGER,
|
||||
Keyboard.CTRL_KEY_WIDTH_PX,
|
||||
Keyboard.DEFAULT_KEY_SIZE_PX,
|
||||
KeyButton.RIGHT_FUNCTION_KEY
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,17 +1,11 @@
|
||||
/////////////////////////////
|
||||
// Loading
|
||||
var Loading = {
|
||||
|
||||
// var x = 32;
|
||||
// var y = 80;
|
||||
|
||||
class Loading {
|
||||
|
||||
preload() {
|
||||
preload: function() {
|
||||
// this.game.load.image('loadingbar', './image/phaser.png');
|
||||
}
|
||||
},
|
||||
|
||||
create() {
|
||||
// let userID = sessionStorage.getItem("UserID");
|
||||
create: function() {
|
||||
// var userID = sessionStorage.getItem("UserID");
|
||||
// console.log("userID : " + userID);
|
||||
|
||||
// this.game.stage.backgroundColor = '#4d4d4d';
|
||||
@@ -30,9 +24,9 @@ class Loading {
|
||||
this.game.load.onLoadComplete.add(this.loadComplete, this);
|
||||
|
||||
this.startLoading();
|
||||
}
|
||||
},
|
||||
|
||||
startLoading() {
|
||||
startLoading: function() {
|
||||
this.game.load.image('icon_fullscreen', '../../../resources/image/icon/fullscreen_white.png');
|
||||
|
||||
this.game.load.image('hand_palm', '../../../resources/image/ui/hand_palm.png');
|
||||
@@ -70,9 +64,9 @@ class Loading {
|
||||
// this.game.load.image('medal_bronze', './image/medal_bronze.png');
|
||||
|
||||
this.game.load.start();
|
||||
}
|
||||
},
|
||||
|
||||
fileComplete(progress, cacheKey, success, totalLoaded, totalFiles) {
|
||||
fileComplete: function(progress, cacheKey, success, totalLoaded, totalFiles) {
|
||||
// this.preloadBar.alpha = progress / 100;
|
||||
|
||||
// console.log('progress : ' + progress);
|
||||
@@ -88,9 +82,9 @@ class Loading {
|
||||
// x = 32;
|
||||
// y += 332;
|
||||
// }
|
||||
}
|
||||
},
|
||||
|
||||
loadComplete(progress, cacheKey, success, totalLoaded, totalFiles) {
|
||||
loadComplete: function(progress, cacheKey, success, totalLoaded, totalFiles) {
|
||||
// this.preloadBar.alpha = 1;
|
||||
|
||||
if(isDebugMode()) {
|
||||
|
||||
@@ -1,67 +1,63 @@
|
||||
class StageTimer {
|
||||
function StageTimer(stageTimerSec, onTimeOver) {
|
||||
this.stageTimerSec = stageTimerSec;
|
||||
this.onTimeOver = onTimeOver;
|
||||
|
||||
constructor(stageTimerSec, onTimeOver) {
|
||||
var fontStyle = StageTimer.DEFAULT_TEXT_FONT;
|
||||
|
||||
this.stageTimerSec = stageTimerSec;
|
||||
this.onTimeOver = onTimeOver;
|
||||
fontStyle.align = "right";
|
||||
fontStyle.boundsAlignH = "right";
|
||||
this.timerText = game.add.text(game.world.width - 300, 0, "", fontStyle)
|
||||
.setTextBounds(0, 0, 200, StageTimer.FONT_HEIGHT_PX);
|
||||
|
||||
let fontStyle = StageTimer.DEFAULT_TEXT_FONT;
|
||||
// var grd = this.label.context.createLinearGradient(0, 0, 0, StageTimer.FONT_HEIGHT_PX);
|
||||
// grd.addColorStop(0, '#8ED6FF');
|
||||
// grd.addColorStop(1, '#004CB3');
|
||||
// this.label.fill = grd;
|
||||
// this.scoreText.fill = grd;
|
||||
|
||||
fontStyle.align = "right";
|
||||
fontStyle.boundsAlignH = "right";
|
||||
this.timerText = game.add.text(game.world.width - 300, 0, "", fontStyle)
|
||||
.setTextBounds(0, 0, 200, StageTimer.FONT_HEIGHT_PX);
|
||||
// this.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
|
||||
// this.label.stroke = '#000';
|
||||
// this.label.strokeThickness = 3;
|
||||
|
||||
// var grd = this.label.context.createLinearGradient(0, 0, 0, StageTimer.FONT_HEIGHT_PX);
|
||||
// grd.addColorStop(0, '#8ED6FF');
|
||||
// grd.addColorStop(1, '#004CB3');
|
||||
// this.label.fill = grd;
|
||||
// this.scoreText.fill = grd;
|
||||
|
||||
// this.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
|
||||
// this.label.stroke = '#000';
|
||||
// this.label.strokeThickness = 3;
|
||||
|
||||
this.timerEvent = null;
|
||||
};
|
||||
|
||||
start() {
|
||||
this.timeLeft = this.stageTimerSec;
|
||||
this.printTime();
|
||||
if(this.timerEvent === null)
|
||||
this.timerEvent = game.time.events.loop(Phaser.Timer.SECOND, this.updateTimer, this);
|
||||
}
|
||||
|
||||
pause() {
|
||||
}
|
||||
|
||||
stop() {
|
||||
if(this.timerEvent)
|
||||
this.removeTimer();
|
||||
this.timerText.text = "시간 끝";
|
||||
}
|
||||
|
||||
updateTimer() {
|
||||
this.timeLeft--;
|
||||
if(this.timeLeft === 0) {
|
||||
this.stop();
|
||||
this.onTimeOver();
|
||||
} else {
|
||||
this.printTime();
|
||||
}
|
||||
}
|
||||
|
||||
printTime() {
|
||||
this.timerText.text = this.timeLeft.toString() + "초";
|
||||
}
|
||||
|
||||
removeTimer() {
|
||||
game.time.events.remove(this.timerEvent);
|
||||
this.timerEvent = null;
|
||||
}
|
||||
this.timerEvent = null;
|
||||
};
|
||||
|
||||
StageTimer.prototype.start = function() {
|
||||
this.timeLeft = this.stageTimerSec;
|
||||
this.printTime();
|
||||
if(this.timerEvent === null)
|
||||
this.timerEvent = game.time.events.loop(Phaser.Timer.SECOND, this.updateTimer, this);
|
||||
}
|
||||
|
||||
StageTimer.prototype.pause = function() {
|
||||
}
|
||||
|
||||
StageTimer.prototype.stop = function() {
|
||||
if(this.timerEvent)
|
||||
this.removeTimer();
|
||||
this.timerText.text = "시간 끝";
|
||||
}
|
||||
|
||||
StageTimer.prototype.updateTimer = function() {
|
||||
this.timeLeft--;
|
||||
if(this.timeLeft === 0) {
|
||||
this.stop();
|
||||
this.onTimeOver();
|
||||
} else {
|
||||
this.printTime();
|
||||
}
|
||||
}
|
||||
|
||||
StageTimer.prototype.printTime = function() {
|
||||
this.timerText.text = this.timeLeft.toString() + "초";
|
||||
}
|
||||
|
||||
StageTimer.prototype.removeTimer = function() {
|
||||
game.time.events.remove(this.timerEvent);
|
||||
this.timerEvent = null;
|
||||
}
|
||||
|
||||
|
||||
StageTimer.FONT_HEIGHT_PX = 70;
|
||||
|
||||
StageTimer.DEFAULT_TEXT_FONT = {
|
||||
|
||||
@@ -1,57 +1,54 @@
|
||||
class TypingScore {
|
||||
function TypingScore() {
|
||||
this.typingCount = 0;
|
||||
|
||||
constructor() {
|
||||
this.typingCount = 0;
|
||||
var fontStyle = TypingScore.DEFAULT_TEXT_FONT;
|
||||
|
||||
let fontStyle = TypingScore.DEFAULT_TEXT_FONT;
|
||||
fontStyle.align = "right";
|
||||
fontStyle.boundsAlignH = "right";
|
||||
this.scoreTitleText = game.add.text(game.world.width / 2 - 40, TypingScore.SCORE_POS_Y, "연속 성공 타수 : ", fontStyle)
|
||||
this.scoreTitleText.anchor.set(0.5);
|
||||
|
||||
fontStyle.align = "right";
|
||||
fontStyle.boundsAlignH = "right";
|
||||
this.scoreTitleText = game.add.text(game.world.width / 2 - 40, TypingScore.SCORE_POS_Y, "연속 성공 타수 : ", fontStyle)
|
||||
this.scoreTitleText.anchor.set(0.5);
|
||||
fontStyle.align = "left";
|
||||
fontStyle.boundsAlignH = "left";
|
||||
this.scoreText = game.add.text(game.world.width / 2 + 100, TypingScore.SCORE_POS_Y, "0", fontStyle)
|
||||
this.scoreText.anchor.set(0.5);
|
||||
|
||||
fontStyle.align = "left";
|
||||
fontStyle.boundsAlignH = "left";
|
||||
this.scoreText = game.add.text(game.world.width / 2 + 100, TypingScore.SCORE_POS_Y, "0", fontStyle)
|
||||
this.scoreText.anchor.set(0.5);
|
||||
// var grd = this.scoreText.context.createLinearGradient(0, 0, 0, TypingScore.SCORE_POS_Y);
|
||||
// grd.addColorStop(0, '#8ED6FF');
|
||||
// grd.addColorStop(1, '#004CB3');
|
||||
// this.scoreText.fill = grd;
|
||||
// this.scoreText.fill = grd;
|
||||
|
||||
// var grd = this.scoreText.context.createLinearGradient(0, 0, 0, TypingScore.SCORE_POS_Y);
|
||||
// grd.addColorStop(0, '#8ED6FF');
|
||||
// grd.addColorStop(1, '#004CB3');
|
||||
// this.scoreText.fill = grd;
|
||||
// this.scoreText.fill = grd;
|
||||
|
||||
// this.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
|
||||
// this.scoreText.stroke = '#000';
|
||||
// this.scoreText.strokeThickness = 3;
|
||||
};
|
||||
|
||||
score() {
|
||||
return this.typingCount;
|
||||
}
|
||||
|
||||
increase() {
|
||||
this.typingCount++;
|
||||
this.print(this.typingCount);
|
||||
}
|
||||
|
||||
reset() {
|
||||
this.typingCount = 0;
|
||||
this.print(this.typingCount);
|
||||
}
|
||||
|
||||
print(typingCount) {
|
||||
this.scoreText.text = typingCount;
|
||||
}
|
||||
// this.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
|
||||
// this.scoreText.stroke = '#000';
|
||||
// this.scoreText.strokeThickness = 3;
|
||||
};
|
||||
|
||||
TypingScore.prototype.score = function() {
|
||||
return this.typingCount;
|
||||
}
|
||||
|
||||
TypingScore.prototype.increase = function() {
|
||||
this.typingCount++;
|
||||
this.print(this.typingCount);
|
||||
}
|
||||
|
||||
TypingScore.prototype.reset = function() {
|
||||
this.typingCount = 0;
|
||||
this.print(this.typingCount);
|
||||
}
|
||||
|
||||
TypingScore.prototype.print = function(typingCount) {
|
||||
this.scoreText.text = typingCount;
|
||||
}
|
||||
|
||||
|
||||
TypingScore.SCORE_POS_Y = 35;
|
||||
|
||||
TypingScore.DEFAULT_TEXT_FONT = {
|
||||
font: "38px Arial",
|
||||
align: "center",
|
||||
boundsAlignH: "center", // left, center. right
|
||||
boundsAlignV: "middle", // top, middle, bottom
|
||||
fill: "#fff"
|
||||
font: "38px Arial",
|
||||
align: "center",
|
||||
boundsAlignH: "center", // left, center. right
|
||||
boundsAlignV: "middle", // top, middle, bottom
|
||||
fill: "#fff"
|
||||
};
|
||||
@@ -1,35 +1,32 @@
|
||||
class AverageTypingSpeed {
|
||||
function AverageTypingSpeed() {
|
||||
var fontStyle = AverageTypingSpeed.DEFAULT_TEXT_FONT;
|
||||
|
||||
constructor() {
|
||||
let fontStyle = AverageTypingSpeed.DEFAULT_TEXT_FONT;
|
||||
fontStyle.align = "right";
|
||||
fontStyle.boundsAlignH = "right";
|
||||
this.tytleSpeedText = game.add.text(game.world.width / 2 + 20, AverageTypingSpeed.FONT_HEIGHT_PX, "현재 타수 : ", fontStyle);
|
||||
this.tytleSpeedText.anchor.set(1, 0.5);
|
||||
|
||||
fontStyle.align = "right";
|
||||
fontStyle.boundsAlignH = "right";
|
||||
this.tytleSpeedText = game.add.text(game.world.width / 2 + 20, AverageTypingSpeed.FONT_HEIGHT_PX, "현재 타수 : ", fontStyle);
|
||||
this.tytleSpeedText.anchor.set(1, 0.5);
|
||||
fontStyle.align = "left";
|
||||
fontStyle.boundsAlignH = "left";
|
||||
this.typingSpeedText = game.add.text(game.world.width / 2 + 20, AverageTypingSpeed.FONT_HEIGHT_PX, "0", fontStyle);
|
||||
this.typingSpeedText.anchor.set(0, 0.5);
|
||||
|
||||
fontStyle.align = "left";
|
||||
fontStyle.boundsAlignH = "left";
|
||||
this.typingSpeedText = game.add.text(game.world.width / 2 + 20, AverageTypingSpeed.FONT_HEIGHT_PX, "0", fontStyle);
|
||||
this.typingSpeedText.anchor.set(0, 0.5);
|
||||
// var grd = this.label.context.createLinearGradient(0, 0, 0, AverageTypingSpeed.FONT_HEIGHT_PX);
|
||||
// grd.addColorStop(0, '#8ED6FF');
|
||||
// grd.addColorStop(1, '#004CB3');
|
||||
// this.label.fill = grd;
|
||||
// this.scoreText.fill = grd;
|
||||
|
||||
// var grd = this.label.context.createLinearGradient(0, 0, 0, AverageTypingSpeed.FONT_HEIGHT_PX);
|
||||
// grd.addColorStop(0, '#8ED6FF');
|
||||
// grd.addColorStop(1, '#004CB3');
|
||||
// this.label.fill = grd;
|
||||
// this.scoreText.fill = grd;
|
||||
|
||||
// this.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
|
||||
// this.label.stroke = '#000';
|
||||
// this.label.strokeThickness = 3;
|
||||
};
|
||||
|
||||
print(typingSpeed) {
|
||||
this.typingSpeedText.text = typingSpeed;
|
||||
}
|
||||
// this.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
|
||||
// this.label.stroke = '#000';
|
||||
// this.label.strokeThickness = 3;
|
||||
};
|
||||
|
||||
AverageTypingSpeed.prototype.print = function(typingSpeed) {
|
||||
this.typingSpeedText.text = typingSpeed;
|
||||
}
|
||||
|
||||
|
||||
AverageTypingSpeed.FONT_HEIGHT_PX = 30;
|
||||
|
||||
AverageTypingSpeed.DEFAULT_TEXT_FONT = {
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
/////////////////////////////
|
||||
// TypingTest
|
||||
var TypingTest = {
|
||||
|
||||
class TypingTest {
|
||||
|
||||
create() {
|
||||
create: function() {
|
||||
self = this;
|
||||
|
||||
this.initTypingData();
|
||||
sessionStorageManager.isNewBestRecrd = false;
|
||||
sessionStorageManager.setIsNewBestRecord(false);
|
||||
|
||||
game.stage.backgroundColor = '#4d4d4d';
|
||||
|
||||
@@ -105,14 +102,14 @@ class TypingTest {
|
||||
|
||||
// bottom ui
|
||||
let screenBottomUI = new ScreenBottomUI();
|
||||
screenBottomUI.printLeftTextWithBestRecord(sessionStorageManager.bestRecord);
|
||||
screenBottomUI.printCenterText(sessionStorageManager.playingAppKoreanName);
|
||||
screenBottomUI.printRightText(sessionStorageManager.playerName);
|
||||
screenBottomUI.printLeftTextWithBestRecord(sessionStorageManager.getBestRecord());
|
||||
screenBottomUI.printCenterText(sessionStorageManager.getPlayingAppKoreanName());
|
||||
screenBottomUI.printRightText(sessionStorageManager.getPlayerName());
|
||||
|
||||
|
||||
this.startGame();
|
||||
// this.countDown();
|
||||
}
|
||||
},
|
||||
|
||||
/*
|
||||
countDown() {
|
||||
@@ -145,30 +142,30 @@ class TypingTest {
|
||||
}
|
||||
*/
|
||||
|
||||
startGame() {
|
||||
startGame: function() {
|
||||
this.averageTypingSpeedText.print(0);
|
||||
|
||||
this.showTypingTestContents();
|
||||
this.showPlayingWordNumber();
|
||||
}
|
||||
},
|
||||
|
||||
gameOver() {
|
||||
gameOver: function() {
|
||||
let gameOverText = new GameOverText();
|
||||
|
||||
this.animalOnTitle.stopAnimation();
|
||||
|
||||
game.time.events.add(Phaser.Timer.SECOND * 2, this.goResult, this);
|
||||
}
|
||||
},
|
||||
|
||||
goResult() {
|
||||
sessionStorageManager.record = this.typingRecordTotal;
|
||||
if(sessionStorageManager.record > sessionStorageManager.bestRecord)
|
||||
sessionStorageManager.bestRecord = sessionStorageManager.record;
|
||||
goResult: function() {
|
||||
sessionStorageManager.setRecord(this.typingRecordTotal);
|
||||
if(sessionStorageManager.getRecord() > sessionStorageManager.getBestRecord())
|
||||
sessionStorageManager.setBestRecord(sessionStorageManager.record);
|
||||
|
||||
location.href = '../../web/client/result.html';
|
||||
}
|
||||
},
|
||||
|
||||
initTypingData() {
|
||||
initTypingData: function() {
|
||||
let typingTextMan = new TypingTextManager();
|
||||
|
||||
let typingPracticeContents = this.getTypingTestContents();
|
||||
@@ -190,10 +187,10 @@ class TypingTest {
|
||||
|
||||
this.typingLetterCountTotal = 0;
|
||||
this.typingRecordTotal = 0;
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
getTypingTestContents() {
|
||||
getTypingTestContents: function() {
|
||||
let typingTestContents = this.loadTestContent();
|
||||
// console.log('playingStageData.language : ' + playingStageData.language);
|
||||
// console.log('playingStageData.level : ' + playingStageData.level);
|
||||
@@ -207,14 +204,14 @@ class TypingTest {
|
||||
}
|
||||
|
||||
return typingTestContents;
|
||||
}
|
||||
},
|
||||
|
||||
loadTestContent() {
|
||||
loadTestContent: function() {
|
||||
let appName = "";
|
||||
if(isTypingTestStage())
|
||||
appName = sessionStorageManager.playingAppName.substring(5);
|
||||
appName = sessionStorageManager.getPlayingAppName().substring(5);
|
||||
else if(isTypingPracticeStage())
|
||||
appName = sessionStorageManager.playingAppName.substring(9);
|
||||
appName = sessionStorageManager.getPlayingAppName().substring(9);
|
||||
|
||||
let testContent = [];
|
||||
switch(appName) {
|
||||
@@ -276,9 +273,9 @@ class TypingTest {
|
||||
}
|
||||
|
||||
return testContent;
|
||||
}
|
||||
},
|
||||
|
||||
showTypingTestContents() {
|
||||
showTypingTestContents: function() {
|
||||
for(let i = 0; i < TypingTest.TYPING_CONTENT_DONE_COUNT; i++) {
|
||||
let doneIndex = this.typingIndex - i - 1;
|
||||
if(doneIndex < 0) {
|
||||
@@ -304,15 +301,15 @@ class TypingTest {
|
||||
else
|
||||
this.textTypingContentPreview[i].text = "";
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
resetTypingContent() {
|
||||
resetTypingContent: function() {
|
||||
this.textTypingContent.clearColors();
|
||||
this.textTypingContent.addColor(TypingTest.COLOR_CONTENT_INPUT, 0);
|
||||
this.inputTextContent.canvasInput.value('');
|
||||
}
|
||||
},
|
||||
|
||||
checkTypingContents(evnet) {
|
||||
checkTypingContents: function(evnet) {
|
||||
if(event.keyCode == Phaser.Keyboard.ENTER) {
|
||||
// console.log("### enter ###");
|
||||
let inputContent = this.inputTextContent.canvasInput.value();
|
||||
@@ -336,9 +333,9 @@ class TypingTest {
|
||||
|
||||
this.showTypingContentHighlight();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
showTypingContentHighlight() {
|
||||
showTypingContentHighlight: function() {
|
||||
let typingContent = this.typingRandomContents[this.typingIndex];
|
||||
let inputContent = this.inputTextContent.canvasInput.value();
|
||||
|
||||
@@ -358,9 +355,9 @@ class TypingTest {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
calculateTypingRecord(typingContent) {
|
||||
calculateTypingRecord: function(typingContent) {
|
||||
// console.log('입력 단어 : ' + this.typingRandomContents[this.typingIndex]);
|
||||
|
||||
this.isTyping = false;
|
||||
@@ -404,20 +401,20 @@ class TypingTest {
|
||||
this.animalOnTitle.tweenAnimation(Animal.ANIMATION_TYPE_CHANGE);
|
||||
this.animalOnTitle.startAnimation();
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
playNextContent() {
|
||||
playNextContent: function() {
|
||||
this.typingIndex++;
|
||||
this.showTypingTestContents();
|
||||
this.showPlayingWordNumber();
|
||||
this.resetTypingContent();
|
||||
}
|
||||
},
|
||||
|
||||
showPlayingWordNumber() {
|
||||
showPlayingWordNumber: function() {
|
||||
this.contentProgressText.print(this.typingIndex + 1, this.typingContentLength);
|
||||
}
|
||||
},
|
||||
|
||||
setTimeTypingStart() {
|
||||
setTimeTypingStart: function() {
|
||||
this.timeTypingStart = game.time.elapsedSince(0);
|
||||
let timeGap = this.timeTypingStart - this.timeTypingEnd;
|
||||
|
||||
|
||||
@@ -1,17 +1,11 @@
|
||||
/////////////////////////////
|
||||
// Loading
|
||||
var Loading = {
|
||||
|
||||
// var x = 32;
|
||||
// var y = 80;
|
||||
|
||||
class Loading {
|
||||
|
||||
preload() {
|
||||
preload: function() {
|
||||
// this.game.load.image('loadingbar', './image/phaser.png');
|
||||
}
|
||||
},
|
||||
|
||||
create() {
|
||||
// let userID = sessionStorage.getItem("UserID");
|
||||
create: function() {
|
||||
// var userID = sessionStorage.getItem("UserID");
|
||||
// console.log("userID : " + userID);
|
||||
|
||||
// this.game.stage.backgroundColor = '#4d4d4d';
|
||||
@@ -30,9 +24,9 @@ class Loading {
|
||||
this.game.load.onLoadComplete.add(this.loadComplete, this);
|
||||
|
||||
this.startLoading();
|
||||
}
|
||||
},
|
||||
|
||||
startLoading() {
|
||||
startLoading: function() {
|
||||
this.game.load.image('icon_fullscreen', '../../../resources/image/icon/fullscreen_white.png');
|
||||
|
||||
Animal.loadResources();
|
||||
@@ -61,9 +55,9 @@ class Loading {
|
||||
// this.game.load.image('medal_bronze', './image/medal_bronze.png');
|
||||
|
||||
this.game.load.start();
|
||||
}
|
||||
},
|
||||
|
||||
fileComplete(progress, cacheKey, success, totalLoaded, totalFiles) {
|
||||
fileComplete: function(progress, cacheKey, success, totalLoaded, totalFiles) {
|
||||
// this.preloadBar.alpha = progress / 100;
|
||||
|
||||
// console.log('progress : ' + progress);
|
||||
@@ -79,9 +73,9 @@ class Loading {
|
||||
// x = 32;
|
||||
// y += 332;
|
||||
// }
|
||||
}
|
||||
},
|
||||
|
||||
loadComplete(progress, cacheKey, success, totalLoaded, totalFiles) {
|
||||
loadComplete: function(progress, cacheKey, success, totalLoaded, totalFiles) {
|
||||
// this.preloadBar.alpha = 1;
|
||||
|
||||
if(isDebugMode()) {
|
||||
@@ -93,5 +87,5 @@ class Loading {
|
||||
// this.startMenu();
|
||||
// this.startTypingTestStage();
|
||||
// this.startTypingTestResult();
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user