Commit 01621ec2 authored by Christof Musik's avatar Christof Musik
Browse files

stop eventhandler if levelset is changed, save current level per levelset

parent 737f39da
......@@ -14,17 +14,20 @@ MainAssistant.prototype.setup = function(){
this.ctx = this.canvas.getContext('2d');
this.ctx.save();
this.controller.listen(this.controller.document, 'keypress', this.handleKeyPress.bind(this));
this.keyPressEventHandler = this.handleKeyPress.bind(this);
this.controller.listen(this.controller.document, 'keypress', this.keyPressEventHandler);
this.readLevels();
this.levelSettings = new Mojo.Model.Cookie("level");
this.levelSettings = new Mojo.Model.Cookie(this.levelSet);
}
MainAssistant.prototype.activate = function(event){
}
MainAssistant.prototype.deactivate = function(event){
Mojo.Event.stopListening(this.controller.document, 'keypress', this.keyPressEventHandler);
}
MainAssistant.prototype.cleanup = function(event){
......@@ -435,9 +438,17 @@ MainAssistant.prototype.readLevels = function(){
}
}
var l = this.levelSettings.get();
Mojo.Log.info("type %s", typeof(l));
if (typeof l !== "number") {
l = 0;
}
Mojo.Log.info("read %d level from file", this.levels.length);
this.initLevel("fo", 0);
this.initLevel("fo", l);
}
.bind(this) ,
onFailure: function(r){
......@@ -450,7 +461,7 @@ MainAssistant.prototype.updateStats = function(c) {
if (typeof c !== "undefined") {
this.moves += c;
}
$("stats").innerHTML = "<div>Moves: "+this.moves+" Best: "+this.highscores.get(this.levelSet, this.currentLevel)+"</div>";
$("stats").innerHTML = "<div>Level: "+(this.currentLevel+1)+" Moves: "+this.moves+" Best: "+this.highscores.get(this.levelSet, this.currentLevel)+"</div>";
}
MainAssistant.prototype.handleCommand = function(e){
......
{
"id": "de.senfdax.sokoban",
"version": "0.0.1",
"version": "0.0.2",
"vendor": "senfdax",
"type": "web",
"main": "index.html",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment