Skip to content

Commit

Permalink
Ticket #4 : fixed "front" canvas not being correctly resized
Browse files Browse the repository at this point in the history
  • Loading branch information
obiot committed Oct 12, 2012
1 parent 91bf71c commit 6e93fcf
Showing 1 changed file with 10 additions and 21 deletions.
31 changes: 10 additions & 21 deletions src/video/video.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@
// update the global scaling value
me.sys.scale.set(scale,scale);
// update the display size
me.video.updateDisplaySize(scale);
me.video.updateDisplaySize(me.sys.scale.x, me.sys.scale.y);
}

if (me.sys.autoresize) {
Expand Down Expand Up @@ -393,37 +393,26 @@
* change the display scaling factor
* @name me.video#updateDisplaySize
* @function
* @param {Number} scale scaling value
* @param {Number} scale X scaling value
* @param {Number} scale Y scaling value
*/
api.updateDisplaySize = function(scale) {
// TODO : should take in account the global me.sys.scale vector
// for the autoresize feature to work
if (double_buffering) {
if (scale)
me.sys.scale.set(scale,scale);
else
// to be changed by something else :)
scale = document.getElementById("screen size").value;
me.sys.scale.set(scale, scale);

game_width_zoom = backBufferCanvas.width * me.sys.scale.x;
game_height_zoom = backBufferCanvas.height * me.sys.scale.y;
}
api.updateDisplaySize = function(scaleX, scaleY) {
canvas.width = game_width_zoom = backBufferCanvas.width * scaleX;
canvas.height = game_height_zoom = backBufferCanvas.height * scaleY;
};

/**
* change the canvas size for autoresize
* @name me.video#updateCanvasSize
* @function
* @param {width} width for the canvas
* @param {height} height for the canvas
* @param {Number} width width for the canvas
* @param {Number} height height for the canvas
*/
api.updateCanvasSize = function(width, height) {
game_width_zoom = width;
game_height_zoom = height;
canvas.width = game_width_zoom = width;
canvas.height = game_height_zoom = height;
me.sys.scale.x = game_width_zoom / backBufferCanvas.width;
me.sys.scale.y = game_height_zoom / backBufferCanvas.height;
me.game.repaint();
};

/**
Expand Down

0 comments on commit 6e93fcf

Please sign in to comment.