Add: move hands with keys

This commit is contained in:
2018-06-20 09:12:08 +09:00
parent 6a5a2db670
commit ba3b88793b
3 changed files with 132 additions and 80 deletions
+76 -29
View File
@@ -2,7 +2,6 @@ class Hand {
constructor(keyMapper) {
this.keyMapper = keyMapper;
console.log(this.keyMapper);
this.pressingFinger = KeyButton.NONE_FINGER;
this.hand = game.add.image(0, Hand.DEFAULT_Y_PX, "hand_palm");
@@ -37,14 +36,14 @@ class Hand {
}
moveRow(no) {
let rowIndex = no - 1;
moveRow(rowNo, key) {
let rowIndex = rowNo - 1;
this.hand.y = Hand.DEFAULT_Y_PX + Keyboard.DEFAULT_KEY_SIZE_PX * rowIndex;
this.moveColumn(no);
this.moveColumn(rowNo, key);
}
moveColumn(no) {
moveColumn(rowNo, key) {
}
@@ -107,36 +106,60 @@ class LeftHand extends Hand {
constructor(keyMapper) {
super(keyMapper);
this.moveRow(3);
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();
}
moveToDefaultPosition() {
this.moveRow(3, null);
}
moveTo(key) {
console.log(key);
if(key === undefined)
return;
// console.log(key);
let keyCode = this.keyMapper.getKeyIDOfText(key.normalText);
if(keyCode != "Space")
this.moveRow(key.row);
this.moveRow(key.row, key);
else
this.moveRow(3);
this.moveRow(3, key);
switch(key.keyCode) {
case "key5":
case "keyT":
case "keyG":
case "keyB":
this.moveColumn(5);
case "Key5":
case "KeyT":
case "KeyG":
case "KeyB":
this.moveColumn(5, key);
break;
}
}
moveColumn(no) {
let colIndex = no - 1;
this.hand.x = LeftHand.DEFAULT_X_PX + (Keyboard.DEFAULT_KEY_SIZE_PX / 2) * colIndex;
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;
}
}
}
@@ -152,36 +175,60 @@ class RightHand extends Hand {
this.hand.scale.x *= -1;
this.moveRow(3);
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();
}
moveToDefaultPosition() {
this.moveRow(3, null);
}
moveTo(key) {
console.log(key);
if(key === undefined)
return;
// console.log(key);
let keyCode = this.keyMapper.getKeyIDOfText(key.normalText);
if(keyCode != "Space")
this.moveRow(key.row);
this.moveRow(key.row, key);
else
this.moveRow(3);
this.moveRow(3, key);
switch(key.keyCode) {
case "key5":
case "keyT":
case "keyG":
case "keyB":
this.moveColumn(5);
case "Key5":
case "KeyT":
case "KeyG":
case "KeyB":
this.moveColumn(5, key);
break;
}
}
moveColumn(no) {
let colIndex = no - 1;
this.hand.x = RightHand.DEFAULT_X_PX + (Keyboard.DEFAULT_KEY_SIZE_PX / 2) * colIndex;
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 "ShiftRight":
this.hand.x = RightHand.DEFAULT_X_PX + (Keyboard.DEFAULT_KEY_SIZE_PX / 2) * 6;
break;
}
}
}