me.video

video functions There is no constructor function for me.video

Members

static AUTO :Number

Auto-select the renderer (Attempt WebGL first, with fallback to Canvas)

static CANVAS :Number

Select the HTML5 Canvas renderer

static renderer :me.Renderer|me.CanvasRenderer|me.WebGLRenderer

A reference to the current video renderer

static WEBGL :Number

Select the WebGL renderer

Methods

static createCanvas(width, height) → {Canvas}

Create and return a new Canvas

Parameters:
Name Type Description
width Number

width

height Number

height

Returns:
Canvas

static getPos()

Deprecated:
  • since 7.0.0
See:

static getWrapper() → {Document}

return a reference to the wrapper

Returns:
Document

static init(width, height, optionsopt) → {Boolean}

Initialize the "video" system (create a canvas based on the given arguments, and the related renderer).
melonJS support various scaling mode, that can be enabled once the scale option is set to auto :

  • fit : Letterboxed; content is scaled to design aspect ratio

  • fill-min : Canvas is resized to fit minimum design resolution; content is scaled to design aspect ratio

  • fill-max : Canvas is resized to fit maximum design resolution; content is scaled to design aspect ratio

  • flex< : Canvas width & height is resized to fit; content is scaled to design aspect ratio

  • flex-width : Canvas width is resized to fit; content is scaled to design aspect ratio

  • flex-height : Canvas height is resized to fit; content is scaled to design aspect ratio

  • stretch : Canvas is resized to fit; content is scaled to screen aspect ratio

Parameters:
Name Type Attributes Description
width Number

the width of the canvas viewport

height Number

the height of the canvas viewport

options Object <optional>

The optional video/renderer parameters.
(see Renderer(s) documentation for further specific options)

Properties
Name Type Attributes Default Description
wrapper String <optional>
document.body

the "div" element name to hold the canvas in the HTML file

renderer Number <optional>
me.video.AUTO

renderer to use.

doubleBuffering Boolean <optional>
false

enable/disable double buffering

scale Number | String <optional>
1.0

enable scaling of the canvas ('auto' for automatic scaling)

scaleMethod String <optional>
"fit"

screen scaling modes ('fit','fill-min','fill-max','flex','flex-width','flex-height','stretch')

useParentDOMSize Boolean <optional>
false

on browser devices, limit the canvas width and height to its parent container dimensions as returned by getBoundingClientRect(), as opposed to the browser window dimensions

transparent Boolean <optional>
false

whether to allow transparent pixels in the front buffer (screen)

antiAlias Boolean <optional>
false

whether to enable or not video scaling interpolation

consoleHeader Boolean <optional>
true

whether to display melonJS version and basic device information in the console

Returns:
Boolean -

false if initialization failed (canvas not supported)

See:
Example
// init the video with a 640x480 canvas
me.video.init(640, 480, {
    wrapper : "screen",
    renderer : me.video.AUTO,
    scale : "auto",
    scaleMethod : "fit",
    doubleBuffering : true
});

static setMaxSize(width, height)

set the max canvas display size (when scaling)

Parameters:
Name Type Description
width Number

width

height Number

height

static updateDisplaySize(scaleX, scaleY)

Modify the "displayed" canvas size

Parameters:
Name Type Description
scaleX Number

X scaling multiplier

scaleY Number

Y scaling multiplier