taiko-web/public/src/js/tutorial.js

36 lines
1.0 KiB
JavaScript
Raw Normal View History

2018-09-18 00:37:59 +02:00
class Tutorial{
2018-09-26 20:30:57 +02:00
constructor(fromSongSel){
this.fromSongSel = fromSongSel
loader.changePage("tutorial", true)
2018-09-18 00:37:59 +02:00
assets.sounds["bgm_setsume"].playLoop(0.1, false, 0, 1.054, 16.054)
this.endButton = document.getElementById("tutorial-end-button")
2018-10-12 20:04:28 +02:00
pageEvents.once(this.endButton, ["mousedown", "touchstart"]).then(this.onEnd.bind(this))
2018-09-26 20:30:57 +02:00
pageEvents.keyOnce(this, 13, "down").then(this.onEnd.bind(this))
2018-09-26 20:30:57 +02:00
this.gamepad = new Gamepad({
2018-10-08 22:32:25 +02:00
"confirm": ["start", "b", "ls", "rs"]
2018-09-26 20:30:57 +02:00
}, this.onEnd.bind(this))
2018-09-18 00:37:59 +02:00
}
onEnd(event){
var touched = false
if(event && event.type === "touchstart"){
event.preventDefault()
touched = true
}
2018-09-18 00:37:59 +02:00
this.clean()
assets.sounds["don"].play()
localStorage.setItem("tutorial", "true")
2018-09-26 20:30:57 +02:00
setTimeout(() => {
2018-10-14 10:04:31 +02:00
new SongSelect(this.fromSongSel ? "tutorial" : false, false, touched)
2018-09-26 20:30:57 +02:00
}, 500)
2018-09-18 00:37:59 +02:00
}
clean(){
2018-09-26 20:30:57 +02:00
this.gamepad.clean()
2018-09-18 00:37:59 +02:00
assets.sounds["bgm_setsume"].stop()
2018-10-12 20:04:28 +02:00
pageEvents.remove(this.endButton, ["mousedown", "touchstart"])
2018-09-26 20:30:57 +02:00
pageEvents.keyRemove(this, 13)
2018-09-18 00:37:59 +02:00
delete this.endButton
}
}