Clean up classes before exiting them

This commit is contained in:
LoveEevee
2018-09-18 01:37:59 +03:00
parent f19fbf5371
commit e8809285e0
25 changed files with 1183 additions and 1172 deletions

View File

@@ -1,53 +1,24 @@
function Titlescreen(){
var _this = this;
$("body").css("font-family", "TnT");
this.positionning = function(){
var width = 0.70*$(window).width();
var logoW = (width>=654) ? 654 : width;
var logoH = logoW/2.18;
$("#logo-big-cont").width(logoW);
$("#logo-big-cont").height(logoH);
$("#logo-big-cont").css("left", $(window).width()/2-($("#logo-big-cont").width()/2));
$("#logo-big-cont").css("top", $(window).height()/2-($("#logo-big-cont").height()/2));
class Titlescreen{
constructor(){
loader.changePage("titlescreen")
this.titleScreen = document.getElementById("title-screen")
pageEvents.keyOnce(this, 13, "down").then(this.goNext.bind(this))
pageEvents.once(this.titleScreen, "click").then(this.goNext.bind(this))
assets.sounds["title"].play()
}
this.run = function(){
$(document).keypress(function(e){
if(e.keyCode==13 && $("#screen").find("#title-screen").html())
_this.goNext();
});
$("#screen").find("#title-screen").click(function(){
_this.goNext();
});
_this.positionning();
$("#screen").find("#title-screen").show();
$(window).resize(_this.positionning);
assets.sounds["title"].play();
}
this.goNext = function(){
assets.sounds["title"].pause();
assets.sounds["title"].currentTime = 0;
assets.sounds["don"].play();
if (localStorage.getItem('tutorial') !== 'true') {
new Tutorial();
} else {
new SongSelect();
};
}
$("#screen").load("/src/views/titlescreen.html", _this.run);
}
goNext(){
this.clean()
assets.sounds["don"].play()
if(localStorage.getItem("tutorial") !== "true"){
new Tutorial()
} else {
new SongSelect()
}
}
clean(){
assets.sounds["title"].stop()
pageEvents.keyRemove(this, 13)
pageEvents.remove(this.titleScreen, "click")
delete this.titleScreen
}
}