Description

(>=1.2.6) Change the size of the canvas or put in full screen

Tested on :

  • Windows 7 - Chrome 26, Firefox 20, Internet Explorer 9 and 10, Opera 12.15, Safari 5.1.7
  • iPad ; iOS 6.1.2 - Safari, Google Chrome
  • Android 2.3.4 - Default Android Browser, Firefox

Usage

Parameters

  • width {Integer|String}

    Width in pixels or indicating the size of the expansion :

    • fullscreen : Put in full screen (HTML5 Fullscreen)

      Support Fullscreen :

      • Chrome 15+
      • Firefox 10+
      • Safari 5.1+
      • Opera 12.50+

      For browsers that do not support full screen, we do a full screen in the browser

    • browser : Put the canvas in full screen in the browser. The canvas is the fixed position in CSS

    • reset : Resets the size of the canvas (the hands and departure)

  • height {Integer} optional

    (optional) Height in pixels

  • scale {String} optional

    (optional) type of scale : stretch or fit

Returns

CanvasEngine.Canvas

Example

In ready method.

var _canvas = this.getCanvas(); // "this" is current scene.

Example 1

_canvas.setSize(400, 300, "fit");

Example 2

_canvas.setSize("browser");

Example 3

_canvas.setSize("browser", "stretch");

Example 4

stage.click(function(e, mouse) {
    _canvas.setSize("fullscreen", "fit");
});

Example 5

_canvas.setSize("reset");

Discussion