utils

namespace utils

string

a collection of utility functions

Summary


Public Methods


checkVersion utils.js:18
checkVersion(first: string, second: string) → {number}

Compare two version strings

if (me.utils.checkVersion("7.0.0") > 0) {
    console.error(
        "melonJS is too old. Expected: 7.0.0, Got: 6.3.0"
    );
}
Parameters:
Name Type Description
first string

First version string to compare

second string

second version string to compare

Returns:
Type Description
number

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

getUriFragment utils.js:50
getUriFragment(url: string) → {object}

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

// http://www.example.com/index.html#debug&hitbox=true&mytag=value
let UriFragment = me.utils.getUriFragment();
console.log(UriFragment["mytag"]); //> "value"
Properties:
Name Type Attributes Default Description
debug boolean

<optional>

false

display the debug panel (if preloaded)

debugToggleKey string

<optional>

"s"

show/hide the debug panel (if preloaded)

hitbox boolean

<optional>

false

draw the hitbox in the debug panel (if enabled)

quadtree boolean

<optional>

false

draw the quadtree in the debug panel (if enabled)

velocity boolean

<optional>

false

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

webgl boolean

<optional>

false

force the renderer to WebGL

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:
Type Description
object

an object representing the deserialized params string.


Powered by webdoc!