me.utils

a collection of utility functions

Namespaces

array

file

function

string

Methods

static checkVersion(first, secondopt) → {Number}

Compare two version strings

Parameters:
Name Type Attributes Default Description
first String

First version string to compare

second String <optional>
me.version

Second version string to compare

Returns:
Number -

comparison result
< 0 : first < second
0 : first == second
> 0 : first > second

Example
if (me.utils.checkVersion("7.0.0") > 0) {
    console.error(
        "melonJS is too old. Expected: 7.0.0, Got: 6.3.0"
    );
}

static getPixels(image) → {ImageData}

Get image pixels

Parameters:
Name Type Description
image Image | Canvas

Image to read

Returns:
ImageData -

Canvas ImageData object

static getUriFragment(urlopt) → {Object}

parse the fragment (hash) from a URL and returns them into

Parameters:
Name Type Attributes Default Description
url String <optional>
document.location

an optional params string or URL containing fragment (hash) params to be parsed

Returns:
Object -

an object representing the deserialized params string.

Properties:
Name Type Attributes Default Description
hitbox Boolean <optional>
false

draw the hitbox in the debug panel (if enabled)

velocity Boolean <optional>
false

draw the entities velocity in the debug panel (if enabled)

quadtree Boolean <optional>
false

draw the quadtree in the debug panel (if enabled)

webgl Boolean <optional>
false

force the renderer to WebGL

debug Boolean <optional>
false

display the debug panel (if preloaded)

debugToggleKey String <optional>
"s"

show/hide the debug panel (if preloaded)

Example
// http://www.example.com/index.html#debug&hitbox=true&mytag=value
var UriFragment = me.utils.getUriFragment();
console.log(UriFragment["mytag"]); //> "value"