Skip to content
Browse files

handle browser resize

  • Loading branch information...
1 parent fd9f92d commit d414ad367f070e5e6a9d3bd7b9323b879568155e @leedo committed Sep 17, 2011
Showing with 8 additions and 3 deletions.
  1. +8 −3 public/strugglin.js
View
11 public/strugglin.js
@@ -2,11 +2,14 @@ var World = Class.create({
initialize: function(id) {
this.canvas = $(id);
- this.canvas.width = document.viewport.getWidth();
- this.canvas.height = document.viewport.getHeight();
-
this.context = this.canvas.getContext("2d");
this.gridSize = 20; // length of a grid side
+ this.setupCanvas();
+ },
+
+ setupCanvas: function() {
+ this.canvas.width = document.viewport.getWidth();
+ this.canvas.height = document.viewport.getHeight();
this.drawGrid();
},
@@ -41,4 +44,6 @@ var World = Class.create({
document.observe("dom:loaded", function() {
var game = new World("view");
+ window.onresize = game.setupCanvas.bind(game);
});
+

0 comments on commit d414ad3

Please sign in to comment.
Something went wrong with that request. Please try again.