From d315d38c393ff988f882a352ffe9e670aeb1a182 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20R=C3=BCmpelein?= Date: Sat, 18 Oct 2014 18:06:33 +0200 Subject: [PATCH] added function 'reset_bug' that resets the close-tab-bug --- src/jsds_crafty.js | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/jsds_crafty.js b/src/jsds_crafty.js index d003681..d2b595c 100644 --- a/src/jsds_crafty.js +++ b/src/jsds_crafty.js @@ -104,7 +104,6 @@ cur_sel.sel_bon(); } else { - console.log("Hide UIBON"); $('#uibon').hide(); } cur_sel.printoutput(); @@ -124,6 +123,9 @@ cur_sel.printoutput(); } }); + this.bind('KeyUp', function(e) { + cur_sel.printoutput(); + }); return this; }, @@ -151,10 +153,24 @@ /* At the end, disable mouse-control for all creatures */ + var focused = false; + var last_sel; var end_init = function() { Crafty("Creature").each( function() { this.disableControl(); }); + $(window).focus( function() { + last_sel = cur_sel; + }); + }; + + var reset_bug = function() { + Crafty("Thing").each( function() { + this._movement.x=0; + this._movement.y=0; + }); + var g= last_sel.graphelement; + g.attr("x",g.old_pos.x); + g.attr("y", g.old_pos.y); }; - }