Fix: change key input value -> keyCode

This commit is contained in:
2018-06-13 23:05:39 +09:00
parent dc957debe9
commit eb497f59c8
6 changed files with 370 additions and 281 deletions
+103 -60
View File
@@ -11,68 +11,21 @@ class KeyButton {
this.setting.strokeWidthPx = 2;
this.buttonSolid = this.makeButtonSolidSprite(this.setting);
if(handSide == KeyButton.LEFT_HAND)
this.setNormalColor();
else
this.setPressedColor();
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);
}
}
setNormalColor() {
switch(this.fingerType) {
case KeyButton.THUMB:
this.buttonSolid.tint = 0x604d4d;
break;
case KeyButton.INDEX_FINGER:
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;
}
}
setPressedColor() {
switch(this.fingerType) {
case KeyButton.THUMB:
this.buttonSolid.tint = 0xff8080;
break;
case KeyButton.INDEX_FINGER:
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;
}
}
makeButtonSolidSprite(setting) {
let btnTexture = new Phaser.Graphics()
.beginFill(0xffffff, 0.5)
@@ -101,6 +54,27 @@ class KeyButton {
);
}
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 offsetX_px = 4;
let offsetY_px = 5;
@@ -138,6 +112,72 @@ class KeyButton {
}
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;
}
onShiftPressed() {
this.buttonText.text = this.shiftText;
@@ -148,7 +188,7 @@ class KeyButton {
}
/*
mouseOut() {
this.text.fill = this.setting.textColors.out;
this.buttonStroke.tint = this.setting.strokeColors.out;
@@ -184,6 +224,7 @@ class KeyButton {
this.buttonIcon.tint = this.setting.strokeColors.disabled;
}
}
*/
}
@@ -204,8 +245,10 @@ KeyButton.LEFT_HAND = 1;
KeyButton.RIGHT_HAND = 2;
KeyButton.BOTH_HAND = 3;
KeyButton.THUMB = 0;
KeyButton.INDEX_FINGER = 1;
KeyButton.MIDDLE_FINGER = 2;
KeyButton.RING_FINGER = 3;
KeyButton.LITTLE_FINGER = 4;
KeyButton.NONE_FINGER = 0;
KeyButton.THUMB = 1;
KeyButton.INDEX_FINGER = 2;
KeyButton.INDEX_FINGER_BASELINE = 3;
KeyButton.MIDDLE_FINGER = 4;
KeyButton.RING_FINGER = 5;
KeyButton.LITTLE_FINGER = 5;