Skip to content

Commit

Permalink
globalized the active controller handling so not dependent on keyboar…
Browse files Browse the repository at this point in the history
…d or mouse
  • Loading branch information
tanema committed Oct 17, 2011
1 parent c2ed816 commit a30b162
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion js/tile_engine/keyboard.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion js/tile_engine/mouse.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions js/tile_engine/tile_engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ function newTileEngine(){
TileEngine.keyboard.init(TileEngine, TileEngine.main_sprite)
TileEngine.physics_engine.init(TileEngine)
TileEngine.initialized = true;

//Active controller handling
$(TileEngine.canvas).mouseup(function(event){TileEngine.ctx_click = true;})
$(document).keydown(function(event){if(TileEngine._focus)TileEngine.active_controller = TileEngine.keyboard})
.mousedown(function(event){TileEngine.active_controller = TileEngine.mouse;TileEngine.doc_click = true;})
.mouseup(function(event){TileEngine._focus = TileEngine.ctx_click && TileEngine.doc_click;TileEngine.doc_click = TileEngine.ctx_click = false;})

Console.log("Tile Map Initialized");
},
setMapAttributes: function(obj){ //this function must be called prior to initializing tile engine
Expand Down

0 comments on commit a30b162

Please sign in to comment.