diff --git a/sounds/coin.mp3 b/sounds/coin.mp3 new file mode 100644 index 0000000..09f9ca0 Binary files /dev/null and b/sounds/coin.mp3 differ diff --git a/vue.js b/vue.js index e8fef6a..f8b3335 100644 --- a/vue.js +++ b/vue.js @@ -7,25 +7,31 @@ new Vue({ count: 0 }, created() { - window.addEventListener('keydown', this.key); + window.addEventListener('keyup', this.key); }, methods: { key(e) { const code = e.keyCode; if(code === 32) { this.jump(); - } + } }, jump() { this.isJump = true; this.isBounce = true; this.isAppear = true; - }, removeAnimation() { this.isAppear = false; this.isBounce = false; this.count++; - } + this.PlaySound('sounds/coin.mp3'); + }, + PlaySound (sound) { + if(sound) { + var audio = new Audio(sound); + audio.play(); + } + } } })