diff --git a/resources/image/character/Mole_grey_32x32.png b/resources/image/character/Mole_grey_32x32.png new file mode 100644 index 0000000..164c480 Binary files /dev/null and b/resources/image/character/Mole_grey_32x32.png differ diff --git a/resources/image/character/Mole_peach_32x32.png b/resources/image/character/Mole_peach_32x32.png new file mode 100644 index 0000000..bc5645c Binary files /dev/null and b/resources/image/character/Mole_peach_32x32.png differ diff --git a/resources/image/character/mole.afdesign b/resources/image/character/mole.afdesign index e907f46..a95774c 100644 Binary files a/resources/image/character/mole.afdesign and b/resources/image/character/mole.afdesign differ diff --git a/resources/image/character/mole.png b/resources/image/character/mole.png index 831f014..1093020 100644 Binary files a/resources/image/character/mole.png and b/resources/image/character/mole.png differ diff --git a/resources/image/character/mole_grey.png b/resources/image/character/mole_grey.png new file mode 100644 index 0000000..5a7704a Binary files /dev/null and b/resources/image/character/mole_grey.png differ diff --git a/resources/image/character/mole_peach.png b/resources/image/character/mole_peach.png new file mode 100644 index 0000000..c8d9f63 Binary files /dev/null and b/resources/image/character/mole_peach.png differ diff --git a/src/game/typing/whac_a_mole/game.js b/src/game/typing/whac_a_mole/game.js index d2b51db..3079c0c 100644 --- a/src/game/typing/whac_a_mole/game.js +++ b/src/game/typing/whac_a_mole/game.js @@ -336,13 +336,18 @@ var WhacAMole = { return; } - this.textTypingContent.text = this.typingRandomLetters[this.typingIndex]; + var nextLetter = this.typingRandomLetters[this.typingIndex]; + this.textTypingContent.text = nextLetter; // var keyID = this.keyboard.keyMapper.getKeyIDOfText(this.typingRandomLetters[this.typingIndex]); + var keyID = this.keyMapper.getKeyIDOfText(nextLetter); + // console.log(keyID); + this.bigMole.changeColor(keyID); this.bigMole.showUp(); + this.keyboardMole.changeColor(keyID); this.keyboardMole.show(); - this.keyboardMole.moveToKey(this.typingRandomLetters[this.typingIndex]); + this.keyboardMole.moveToKey(nextLetter); for(var i = 0; i < WhacAMole.TYPING_CONTENT_PREVIEW_COUNT; i++) { diff --git a/src/game/typing/whac_a_mole/loading.js b/src/game/typing/whac_a_mole/loading.js index d98138a..bec43ba 100644 --- a/src/game/typing/whac_a_mole/loading.js +++ b/src/game/typing/whac_a_mole/loading.js @@ -29,7 +29,10 @@ var Loading = { startLoading: function() { game.load.image('icon_fullscreen', '../../../resources/image/icon/fullscreen_white.png'); - game.load.image('mole', '../../../resources/image/character/mole.png'); + game.load.image('mole_grey', '../../../resources/image/character/mole_grey.png'); + game.load.image('mole_grey_small', '../../../resources/image/character/mole_grey_32x32.png'); + game.load.image('mole_peach', '../../../resources/image/character/mole_peach.png'); + game.load.image('mole_peach_small', '../../../resources/image/character/mole_peach_32x32.png'); // game.load.image('hand_left', '../../../resources/image/ui/hand_left.png'); diff --git a/src/game/typing/whac_a_mole/mole.js b/src/game/typing/whac_a_mole/mole.js index d403e12..f882dc7 100644 --- a/src/game/typing/whac_a_mole/mole.js +++ b/src/game/typing/whac_a_mole/mole.js @@ -1,9 +1,13 @@ -function Mole(x, y, scale) { - this.mole = game.add.image(x, y, "mole"); - this.mole.scale.set(scale); - // this.move(x, y); +function Mole(x, y, type) { + if(type == Mole.TYPE_BIG_MOLE) { + this.mole = game.add.image(x, y, "mole_grey"); + this.mole.scale.set(BigMole.SCALE); + } else { + this.mole = game.add.image(x, y, "mole_grey_small"); + this.mole.scale.set(KeyboardMole.SCALE); + } - // return this.mole; + this.posY = y; } Mole.prototype.alpha = function(value) { @@ -23,21 +27,17 @@ Mole.prototype.anchor = function(x, y) { } Mole.prototype.showUpTween = function(showUpHeight) { - // if(this.tween != undefined && this.tween.isRunning) { - // this.tween.stop(); - // // this.tween.pendingDelete = false; - // // this.mole.y = BigMole.START_POS_Y; - // } - // console.log(this.mole); - // console.log("this.posY : " + this.posY); this.tween = game.add.tween(this.mole) - .from( { y: BigMole.START_POS_Y }, 10 ) - .to( { y: BigMole.SHOW_UP_POS_Y }, BigMole.SHOW_UP_TIME_MS, "Quart.easeOut"); - // .from( { y: this.posY }, 10 ) - // .to( { y: (this.posY + showUpHeight) }, BigMole.SHOW_UP_TIME_MS, "Quart.easeOut"); + // .from( { y: BigMole.START_POS_Y }, 10 ) + // .to( { y: BigMole.SHOW_UP_POS_Y }, BigMole.SHOW_UP_TIME_MS, "Quart.easeOut"); + .from( { y: this.posY }, 10 ) + .to( { y: (this.posY - showUpHeight) }, BigMole.SHOW_UP_TIME_MS, "Quart.easeOut"); this.tween.start(); } +Mole.TYPE_BIG_MOLE = "big_mole"; +Mole.TYPE_KEYBOARD_MOLE = "kebyard_mole"; + @@ -47,18 +47,25 @@ BigMole.prototype = Object.create(Mole.prototype); BigMole.constructor = BigMole; function BigMole(x, y) { - Mole.call(this, x, y, BigMole.SCALE); + Mole.call(this, x, y, Mole.TYPE_BIG_MOLE); this.anchor(0.5, 0); } BigMole.prototype.showUp = function() { - this.showUpTween(100); + this.showUpTween(BigMole.SHOW_UP_HEIGHT); +} + +BigMole.prototype.changeColor = function(keyID) { + if(keyID == "KeyF" || keyID == "KeyJ") + this.mole.loadTexture("mole_peach"); + else + this.mole.loadTexture("mole_grey"); } BigMole.SCALE = 1; BigMole.START_POS_Y = 200; -BigMole.SHOW_UP_POS_Y = 100; +BigMole.SHOW_UP_HEIGHT = 100; BigMole.SHOW_UP_TIME_MS = 200; @@ -72,7 +79,7 @@ KeyboardMole.constructor = KeyboardMole; function KeyboardMole(keyboard) { this.keyboard = keyboard; - Mole.call(this, 0, 0, KeyboardMole.SCALE); + Mole.call(this, 0, 0, Mole.TYPE_KEYBOARD_MOLE); this.anchor(0, 0); this.hide(); } @@ -86,10 +93,19 @@ KeyboardMole.prototype.hide = function() { } KeyboardMole.prototype.moveToKey = function(text) { - var x = this.keyboard.getKeyPosX(text); - var y = this.keyboard.getKeyPosY(text); + var x = this.keyboard.getKeyPosX(text) + KeyboardMole.OFFSET_X; + var y = this.keyboard.getKeyPosY(text) + KeyboardMole.OFFSET_Y; this.move(x, y); } +KeyboardMole.prototype.changeColor = function(keyID) { + if(keyID == "KeyF" || keyID == "KeyJ") + this.mole.loadTexture("mole_peach_small"); + else + this.mole.loadTexture("mole_grey_small"); +} -KeyboardMole.SCALE = 0.5; \ No newline at end of file + +KeyboardMole.SCALE = 1.2; +KeyboardMole.OFFSET_X = 4; +KeyboardMole.OFFSET_Y = 0;