repo
stringlengths
5
67
path
stringlengths
4
116
func_name
stringlengths
0
58
original_string
stringlengths
52
373k
language
stringclasses
1 value
code
stringlengths
52
373k
code_tokens
list
docstring
stringlengths
4
11.8k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
86
226
partition
stringclasses
1 value
melonjs/melonJS
tasks/jsdoc-template/publish.js
function(src, dest) { var contents, srcExists = fs.existsSync(src), destExists = fs.existsSync(dest), stats = srcExists && fs.statSync(src), isDirectory = srcExists && stats.isDirectory(); if (srcExists) { if (isDirectory) { if (!destExists) { ...
javascript
function(src, dest) { var contents, srcExists = fs.existsSync(src), destExists = fs.existsSync(dest), stats = srcExists && fs.statSync(src), isDirectory = srcExists && stats.isDirectory(); if (srcExists) { if (isDirectory) { if (!destExists) { ...
[ "function", "(", "src", ",", "dest", ")", "{", "var", "contents", ",", "srcExists", "=", "fs", ".", "existsSync", "(", "src", ")", ",", "destExists", "=", "fs", ".", "existsSync", "(", "dest", ")", ",", "stats", "=", "srcExists", "&&", "fs", ".", "...
Look ma, it's cp -R. @param {string} src The path to the thing to copy. @param {string} dest The path to the new copy.
[ "Look", "ma", "it", "s", "cp", "-", "R", "." ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/tasks/jsdoc-template/publish.js#L504-L525
train
melonjs/melonJS
src/font/bitmaptextdata.js
function () { var spaceCharCode = " ".charCodeAt(0); var glyph = this.glyphs[spaceCharCode]; if (!glyph) { glyph = new Glyph(); glyph.id = spaceCharCode; glyph.xadvance = this._getFirstGlyph().xadvance; this.glyphs[space...
javascript
function () { var spaceCharCode = " ".charCodeAt(0); var glyph = this.glyphs[spaceCharCode]; if (!glyph) { glyph = new Glyph(); glyph.id = spaceCharCode; glyph.xadvance = this._getFirstGlyph().xadvance; this.glyphs[space...
[ "function", "(", ")", "{", "var", "spaceCharCode", "=", "\" \"", ".", "charCodeAt", "(", "0", ")", ";", "var", "glyph", "=", "this", ".", "glyphs", "[", "spaceCharCode", "]", ";", "if", "(", "!", "glyph", ")", "{", "glyph", "=", "new", "Glyph", "("...
Creates a glyph to use for the space character @private @name _createSpaceGlyph @memberOf me.BitmapTextData @function
[ "Creates", "a", "glyph", "to", "use", "for", "the", "space", "character" ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/src/font/bitmaptextdata.js#L103-L112
train
melonjs/melonJS
src/physics/body.js
function (response) { // the overlap vector var overlap = response.overlapV; // FIXME: Respond proportionally to object mass // Move out of the other object shape this.ancestor.pos.sub(overlap); // adjust velocity if (overlap.x !== 0...
javascript
function (response) { // the overlap vector var overlap = response.overlapV; // FIXME: Respond proportionally to object mass // Move out of the other object shape this.ancestor.pos.sub(overlap); // adjust velocity if (overlap.x !== 0...
[ "function", "(", "response", ")", "{", "// the overlap vector", "var", "overlap", "=", "response", ".", "overlapV", ";", "// FIXME: Respond proportionally to object mass", "// Move out of the other object shape", "this", ".", "ancestor", ".", "pos", ".", "sub", "(", "ov...
the built-in function to solve the collision response @protected @name respondToCollision @memberOf me.Body @function @param {me.collision.ResponseObject} response the collision response object
[ "the", "built", "-", "in", "function", "to", "solve", "the", "collision", "response" ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/src/physics/body.js#L444-L471
train
melonjs/melonJS
src/physics/body.js
function (vel) { var fx = this.friction.x * me.timer.tick, nx = vel.x + fx, x = vel.x - fx, fy = this.friction.y * me.timer.tick, ny = vel.y + fy, y = vel.y - fy; vel.x = ( (nx < 0) ? nx : ...
javascript
function (vel) { var fx = this.friction.x * me.timer.tick, nx = vel.x + fx, x = vel.x - fx, fy = this.friction.y * me.timer.tick, ny = vel.y + fy, y = vel.y - fy; vel.x = ( (nx < 0) ? nx : ...
[ "function", "(", "vel", ")", "{", "var", "fx", "=", "this", ".", "friction", ".", "x", "*", "me", ".", "timer", ".", "tick", ",", "nx", "=", "vel", ".", "x", "+", "fx", ",", "x", "=", "vel", ".", "x", "-", "fx", ",", "fy", "=", "this", "....
apply friction to a vector @ignore
[ "apply", "friction", "to", "a", "vector" ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/src/physics/body.js#L555-L571
train
melonjs/melonJS
src/entity/draggable.js
function (e) { if (this.dragging === false) { this.dragging = true; this.grabOffset.set(e.gameX, e.gameY); this.grabOffset.sub(this.pos); return false; } }
javascript
function (e) { if (this.dragging === false) { this.dragging = true; this.grabOffset.set(e.gameX, e.gameY); this.grabOffset.sub(this.pos); return false; } }
[ "function", "(", "e", ")", "{", "if", "(", "this", ".", "dragging", "===", "false", ")", "{", "this", ".", "dragging", "=", "true", ";", "this", ".", "grabOffset", ".", "set", "(", "e", ".", "gameX", ",", "e", ".", "gameY", ")", ";", "this", "....
Gets called when the user starts dragging the entity @name dragStart @memberOf me.DraggableEntity @function @param {Object} x the pointer event
[ "Gets", "called", "when", "the", "user", "starts", "dragging", "the", "entity" ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/src/entity/draggable.js#L92-L99
train
melonjs/melonJS
src/entity/draggable.js
function (e) { if (this.dragging === true) { this.pos.set(e.gameX, e.gameY, this.pos.z); //TODO : z ? this.pos.sub(this.grabOffset); } }
javascript
function (e) { if (this.dragging === true) { this.pos.set(e.gameX, e.gameY, this.pos.z); //TODO : z ? this.pos.sub(this.grabOffset); } }
[ "function", "(", "e", ")", "{", "if", "(", "this", ".", "dragging", "===", "true", ")", "{", "this", ".", "pos", ".", "set", "(", "e", ".", "gameX", ",", "e", ".", "gameY", ",", "this", ".", "pos", ".", "z", ")", ";", "//TODO : z ?", "this", ...
Gets called when the user drags this entity around @name dragMove @memberOf me.DraggableEntity @function @param {Object} x the pointer event
[ "Gets", "called", "when", "the", "user", "drags", "this", "entity", "around" ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/src/entity/draggable.js#L108-L113
train
melonjs/melonJS
src/utils/color.js
function (r, g, b, alpha) { // Private initialization: copy Color value directly if (r instanceof me.Color) { this.glArray.set(r.glArray); return r; } this.r = r; this.g = g; this.b = b; this.alpha = alph...
javascript
function (r, g, b, alpha) { // Private initialization: copy Color value directly if (r instanceof me.Color) { this.glArray.set(r.glArray); return r; } this.r = r; this.g = g; this.b = b; this.alpha = alph...
[ "function", "(", "r", ",", "g", ",", "b", ",", "alpha", ")", "{", "// Private initialization: copy Color value directly", "if", "(", "r", "instanceof", "me", ".", "Color", ")", "{", "this", ".", "glArray", ".", "set", "(", "r", ".", "glArray", ")", ";", ...
Set this color to the specified value. @name setColor @memberOf me.Color @function @param {Number} r red component [0 .. 255] @param {Number} g green component [0 .. 255] @param {Number} b blue component [0 .. 255] @param {Number} [alpha=1.0] alpha value [0.0 .. 1.0] @return {me.Color} Reference to this object for meth...
[ "Set", "this", "color", "to", "the", "specified", "value", "." ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/src/utils/color.js#L213-L224
train
melonjs/melonJS
src/utils/color.js
function (color) { if (color instanceof me.Color) { this.glArray.set(color.glArray); return this; } return this.parseCSS(color); }
javascript
function (color) { if (color instanceof me.Color) { this.glArray.set(color.glArray); return this; } return this.parseCSS(color); }
[ "function", "(", "color", ")", "{", "if", "(", "color", "instanceof", "me", ".", "Color", ")", "{", "this", ".", "glArray", ".", "set", "(", "color", ".", "glArray", ")", ";", "return", "this", ";", "}", "return", "this", ".", "parseCSS", "(", "col...
Copy a color object or CSS color into this one. @name copy @memberOf me.Color @function @param {me.Color|String} color @return {me.Color} Reference to this object for method chaining
[ "Copy", "a", "color", "object", "or", "CSS", "color", "into", "this", "one", "." ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/src/utils/color.js#L245-L252
train
melonjs/melonJS
src/utils/color.js
function (color) { this.glArray[0] = me.Math.clamp(this.glArray[0] + color.glArray[0], 0, 1); this.glArray[1] = me.Math.clamp(this.glArray[1] + color.glArray[1], 0, 1); this.glArray[2] = me.Math.clamp(this.glArray[2] + color.glArray[2], 0, 1); this.glArray[3] = (this.glAr...
javascript
function (color) { this.glArray[0] = me.Math.clamp(this.glArray[0] + color.glArray[0], 0, 1); this.glArray[1] = me.Math.clamp(this.glArray[1] + color.glArray[1], 0, 1); this.glArray[2] = me.Math.clamp(this.glArray[2] + color.glArray[2], 0, 1); this.glArray[3] = (this.glAr...
[ "function", "(", "color", ")", "{", "this", ".", "glArray", "[", "0", "]", "=", "me", ".", "Math", ".", "clamp", "(", "this", ".", "glArray", "[", "0", "]", "+", "color", ".", "glArray", "[", "0", "]", ",", "0", ",", "1", ")", ";", "this", ...
Blend this color with the given one using addition. @name add @memberOf me.Color @function @param {me.Color} color @return {me.Color} Reference to this object for method chaining
[ "Blend", "this", "color", "with", "the", "given", "one", "using", "addition", "." ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/src/utils/color.js#L262-L269
train
melonjs/melonJS
src/utils/color.js
function (scale) { scale = me.Math.clamp(scale, 0, 1); this.glArray[0] *= scale; this.glArray[1] *= scale; this.glArray[2] *= scale; return this; }
javascript
function (scale) { scale = me.Math.clamp(scale, 0, 1); this.glArray[0] *= scale; this.glArray[1] *= scale; this.glArray[2] *= scale; return this; }
[ "function", "(", "scale", ")", "{", "scale", "=", "me", ".", "Math", ".", "clamp", "(", "scale", ",", "0", ",", "1", ")", ";", "this", ".", "glArray", "[", "0", "]", "*=", "scale", ";", "this", ".", "glArray", "[", "1", "]", "*=", "scale", ";...
Darken this color value by 0..1 @name darken @memberOf me.Color @function @param {Number} scale @return {me.Color} Reference to this object for method chaining
[ "Darken", "this", "color", "value", "by", "0", "..", "1" ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/src/utils/color.js#L279-L286
train
melonjs/melonJS
src/utils/color.js
function (cssColor) { // TODO : Memoize this function by caching its input if (cssToRGB.has(cssColor)) { return this.setColor.apply(this, cssToRGB.get(cssColor)); } return this.parseRGB(cssColor); }
javascript
function (cssColor) { // TODO : Memoize this function by caching its input if (cssToRGB.has(cssColor)) { return this.setColor.apply(this, cssToRGB.get(cssColor)); } return this.parseRGB(cssColor); }
[ "function", "(", "cssColor", ")", "{", "// TODO : Memoize this function by caching its input", "if", "(", "cssToRGB", ".", "has", "(", "cssColor", ")", ")", "{", "return", "this", ".", "setColor", ".", "apply", "(", "this", ",", "cssToRGB", ".", "get", "(", ...
Parse a CSS color string and set this color to the corresponding r,g,b values @name parseCSS @memberOf me.Color @function @param {String} color @return {me.Color} Reference to this object for method chaining
[ "Parse", "a", "CSS", "color", "string", "and", "set", "this", "color", "to", "the", "corresponding", "r", "g", "b", "values" ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/src/utils/color.js#L348-L356
train
melonjs/melonJS
src/utils/color.js
function (rgbColor) { // TODO : Memoize this function by caching its input var match = rgbaRx.exec(rgbColor); if (match) { return this.setColor(+match[1], +match[2], +match[3], +match[5]); } return this.parseHex(rgbColor); }
javascript
function (rgbColor) { // TODO : Memoize this function by caching its input var match = rgbaRx.exec(rgbColor); if (match) { return this.setColor(+match[1], +match[2], +match[3], +match[5]); } return this.parseHex(rgbColor); }
[ "function", "(", "rgbColor", ")", "{", "// TODO : Memoize this function by caching its input", "var", "match", "=", "rgbaRx", ".", "exec", "(", "rgbColor", ")", ";", "if", "(", "match", ")", "{", "return", "this", ".", "setColor", "(", "+", "match", "[", "1"...
Parse an RGB or RGBA CSS color string @name parseRGB @memberOf me.Color @function @param {String} color @return {me.Color} Reference to this object for method chaining
[ "Parse", "an", "RGB", "or", "RGBA", "CSS", "color", "string" ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/src/utils/color.js#L366-L375
train
melonjs/melonJS
src/level/tiled/TMXTiledMap.js
readLayer
function readLayer(map, data, z) { var layer = new me.TMXLayer(data, map.tilewidth, map.tileheight, map.orientation, map.tilesets, z); // set a renderer layer.setRenderer(map.getRenderer()); return layer; }
javascript
function readLayer(map, data, z) { var layer = new me.TMXLayer(data, map.tilewidth, map.tileheight, map.orientation, map.tilesets, z); // set a renderer layer.setRenderer(map.getRenderer()); return layer; }
[ "function", "readLayer", "(", "map", ",", "data", ",", "z", ")", "{", "var", "layer", "=", "new", "me", ".", "TMXLayer", "(", "data", ",", "map", ".", "tilewidth", ",", "map", ".", "tileheight", ",", "map", ".", "orientation", ",", "map", ".", "til...
read the layer Data @ignore
[ "read", "the", "layer", "Data" ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/src/level/tiled/TMXTiledMap.js#L35-L40
train
melonjs/melonJS
src/level/tiled/TMXTiledMap.js
readImageLayer
function readImageLayer(map, data, z) { // Normalize properties me.TMXUtils.applyTMXProperties(data.properties, data); // create the layer var imageLayer = me.pool.pull("me.ImageLayer", // x/y is deprecated since 0.15 and replace by offsetx/y +data.offsetx || +da...
javascript
function readImageLayer(map, data, z) { // Normalize properties me.TMXUtils.applyTMXProperties(data.properties, data); // create the layer var imageLayer = me.pool.pull("me.ImageLayer", // x/y is deprecated since 0.15 and replace by offsetx/y +data.offsetx || +da...
[ "function", "readImageLayer", "(", "map", ",", "data", ",", "z", ")", "{", "// Normalize properties", "me", ".", "TMXUtils", ".", "applyTMXProperties", "(", "data", ".", "properties", ",", "data", ")", ";", "// create the layer", "var", "imageLayer", "=", "me"...
read the Image Layer Data @ignore
[ "read", "the", "Image", "Layer", "Data" ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/src/level/tiled/TMXTiledMap.js#L46-L67
train
melonjs/melonJS
src/level/tiled/TMXTiledMap.js
function (data) { if (this.initialized === true) { return; } // to automatically increment z index var zOrder = 0; var self = this; // Tileset information if (!this.tilesets) { // make sure we have a T...
javascript
function (data) { if (this.initialized === true) { return; } // to automatically increment z index var zOrder = 0; var self = this; // Tileset information if (!this.tilesets) { // make sure we have a T...
[ "function", "(", "data", ")", "{", "if", "(", "this", ".", "initialized", "===", "true", ")", "{", "return", ";", "}", "// to automatically increment z index", "var", "zOrder", "=", "0", ";", "var", "self", "=", "this", ";", "// Tileset information", "if", ...
parse the map @ignore
[ "parse", "the", "map" ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/src/level/tiled/TMXTiledMap.js#L271-L346
train
melonjs/melonJS
src/level/tiled/TMXTiledMap.js
function (container, flatten) { var _sort = container.autoSort; var _depth = container.autoDepth; // disable auto-sort and auto-depth container.autoSort = false; container.autoDepth = false; // add all layers instances this.getLayers(...
javascript
function (container, flatten) { var _sort = container.autoSort; var _depth = container.autoDepth; // disable auto-sort and auto-depth container.autoSort = false; container.autoDepth = false; // add all layers instances this.getLayers(...
[ "function", "(", "container", ",", "flatten", ")", "{", "var", "_sort", "=", "container", ".", "autoSort", ";", "var", "_depth", "=", "container", ".", "autoDepth", ";", "// disable auto-sort and auto-depth", "container", ".", "autoSort", "=", "false", ";", "c...
add all the map layers and objects to the given container @name me.TMXTileMap#addTo @public @function @param {me.Container} target container @param {boolean} flatten if true, flatten all objects into the given container @example // create a new level object based on the TMX JSON object var level = new me.TMXTileMap(lev...
[ "add", "all", "the", "map", "layers", "and", "objects", "to", "the", "given", "container" ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/src/level/tiled/TMXTiledMap.js#L362-L386
train
melonjs/melonJS
src/video/texture.js
function (data) { var atlas = {}; var image = data.image; var spacing = data.spacing || 0; var margin = data.margin || 0; var width = image.width; var height = image.height; // calculate the sprite count (line, col) var sp...
javascript
function (data) { var atlas = {}; var image = data.image; var spacing = data.spacing || 0; var margin = data.margin || 0; var width = image.width; var height = image.height; // calculate the sprite count (line, col) var sp...
[ "function", "(", "data", ")", "{", "var", "atlas", "=", "{", "}", ";", "var", "image", "=", "data", ".", "image", ";", "var", "spacing", "=", "data", ".", "spacing", "||", "0", ";", "var", "margin", "=", "data", ".", "margin", "||", "0", ";", "...
build an atlas from the given spritesheet @ignore
[ "build", "an", "atlas", "from", "the", "given", "spritesheet" ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/src/video/texture.js#L210-L262
train
melonjs/melonJS
src/video/texture.js
function (name) { // Get the source texture region var region = this.getRegion(name); if (typeof(region) === "undefined") { // TODO: Require proper atlas regions instead of caching arbitrary region keys var keys = name.split(","), ...
javascript
function (name) { // Get the source texture region var region = this.getRegion(name); if (typeof(region) === "undefined") { // TODO: Require proper atlas regions instead of caching arbitrary region keys var keys = name.split(","), ...
[ "function", "(", "name", ")", "{", "// Get the source texture region", "var", "region", "=", "this", ".", "getRegion", "(", "name", ")", ";", "if", "(", "typeof", "(", "region", ")", "===", "\"undefined\"", ")", "{", "// TODO: Require proper atlas regions instead ...
return the uvs mapping for the given region @name getUVs @memberOf me.Renderer.Texture @function @param {Object} region region (or frame) name @return {Float32Array} region Uvs
[ "return", "the", "uvs", "mapping", "for", "the", "given", "region" ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/src/video/texture.js#L381-L395
train
melonjs/melonJS
src/video/texture.js
function (name, settings) { // instantiate a new sprite object return me.pool.pull( "me.Sprite", 0, 0, Object.assign({ image: this, region : name }, settings || {}) ); }
javascript
function (name, settings) { // instantiate a new sprite object return me.pool.pull( "me.Sprite", 0, 0, Object.assign({ image: this, region : name }, settings || {}) ); }
[ "function", "(", "name", ",", "settings", ")", "{", "// instantiate a new sprite object", "return", "me", ".", "pool", ".", "pull", "(", "\"me.Sprite\"", ",", "0", ",", "0", ",", "Object", ".", "assign", "(", "{", "image", ":", "this", ",", "region", ":"...
Create a sprite object using the first region found using the specified name @name createSpriteFromName @memberOf me.Renderer.Texture @function @param {String} name name of the sprite @param {Object} [settings] Additional settings passed to the {@link me.Sprite} contructor @return {me.Sprite} @example // create a new t...
[ "Create", "a", "sprite", "object", "using", "the", "first", "region", "found", "using", "the", "specified", "name" ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/src/video/texture.js#L418-L428
train
melonjs/melonJS
src/state/state.js
_renderFrame
function _renderFrame(time) { var stage = _stages[_state].stage; // update all game objects me.game.update(time, stage); // render all game objects me.game.draw(stage); // schedule the next frame update if (_animFrameId !== -1) { ...
javascript
function _renderFrame(time) { var stage = _stages[_state].stage; // update all game objects me.game.update(time, stage); // render all game objects me.game.draw(stage); // schedule the next frame update if (_animFrameId !== -1) { ...
[ "function", "_renderFrame", "(", "time", ")", "{", "var", "stage", "=", "_stages", "[", "_state", "]", ".", "stage", ";", "// update all game objects", "me", ".", "game", ".", "update", "(", "time", ",", "stage", ")", ";", "// render all game objects", "me",...
this is only called when using requestAnimFrame stuff @param {Number} time current timestamp in milliseconds @ignore
[ "this", "is", "only", "called", "when", "using", "requestAnimFrame", "stuff" ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/src/state/state.js#L87-L97
train
melonjs/melonJS
src/state/state.js
_switchState
function _switchState(state) { // clear previous interval if any _stopRunLoop(); // call the stage destroy method if (_stages[_state]) { // just notify the object _stages[_state].stage.destroy(); } if (_stages[stat...
javascript
function _switchState(state) { // clear previous interval if any _stopRunLoop(); // call the stage destroy method if (_stages[_state]) { // just notify the object _stages[_state].stage.destroy(); } if (_stages[stat...
[ "function", "_switchState", "(", "state", ")", "{", "// clear previous interval if any", "_stopRunLoop", "(", ")", ";", "// call the stage destroy method", "if", "(", "_stages", "[", "_state", "]", ")", "{", "// just notify the object", "_stages", "[", "_state", "]", ...
start the SO main loop @ignore
[ "start", "the", "SO", "main", "loop" ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/src/state/state.js#L113-L142
train
melonjs/melonJS
src/renderable/colorlayer.js
function (renderer, rect) { var color = renderer.getColor(); var vpos = me.game.viewport.pos; renderer.setColor(this.color); renderer.fillRect( rect.left - vpos.x, rect.top - vpos.y, rect.width, rect.height ); render...
javascript
function (renderer, rect) { var color = renderer.getColor(); var vpos = me.game.viewport.pos; renderer.setColor(this.color); renderer.fillRect( rect.left - vpos.x, rect.top - vpos.y, rect.width, rect.height ); render...
[ "function", "(", "renderer", ",", "rect", ")", "{", "var", "color", "=", "renderer", ".", "getColor", "(", ")", ";", "var", "vpos", "=", "me", ".", "game", ".", "viewport", ".", "pos", ";", "renderer", ".", "setColor", "(", "this", ".", "color", ")...
draw the color layer @ignore
[ "draw", "the", "color", "layer" ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/src/renderable/colorlayer.js#L47-L56
train
melonjs/melonJS
src/physics/collision.js
flattenPointsOn
function flattenPointsOn(points, normal, result) { var min = Number.MAX_VALUE; var max = -Number.MAX_VALUE; var len = points.length; for (var i = 0; i < len; i++) { // The magnitude of the projection of the point onto the normal var dot = points[i].dotProduct(norm...
javascript
function flattenPointsOn(points, normal, result) { var min = Number.MAX_VALUE; var max = -Number.MAX_VALUE; var len = points.length; for (var i = 0; i < len; i++) { // The magnitude of the projection of the point onto the normal var dot = points[i].dotProduct(norm...
[ "function", "flattenPointsOn", "(", "points", ",", "normal", ",", "result", ")", "{", "var", "min", "=", "Number", ".", "MAX_VALUE", ";", "var", "max", "=", "-", "Number", ".", "MAX_VALUE", ";", "var", "len", "=", "points", ".", "length", ";", "for", ...
Flattens the specified array of points onto a unit vector axis, resulting in a one dimensional range of the minimum and maximum value on that axis. @param {Array.<Vector>} points The points to flatten. @param {Vector} normal The unit vector axis to flatten on. @param {Array.<number>} result An array. After calling thi...
[ "Flattens", "the", "specified", "array", "of", "points", "onto", "a", "unit", "vector", "axis", "resulting", "in", "a", "one", "dimensional", "range", "of", "the", "minimum", "and", "maximum", "value", "on", "that", "axis", "." ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/src/physics/collision.js#L58-L70
train
melonjs/melonJS
src/loader/loader.js
checkLoadStatus
function checkLoadStatus(onload) { if (loadCount === resourceCount) { // wait 1/2s and execute callback (cheap workaround to ensure everything is loaded) if (onload || api.onload) { // make sure we clear the timer clearTimeout(timerId);...
javascript
function checkLoadStatus(onload) { if (loadCount === resourceCount) { // wait 1/2s and execute callback (cheap workaround to ensure everything is loaded) if (onload || api.onload) { // make sure we clear the timer clearTimeout(timerId);...
[ "function", "checkLoadStatus", "(", "onload", ")", "{", "if", "(", "loadCount", "===", "resourceCount", ")", "{", "// wait 1/2s and execute callback (cheap workaround to ensure everything is loaded)", "if", "(", "onload", "||", "api", ".", "onload", ")", "{", "// make s...
check the loading status @ignore
[ "check", "the", "loading", "status" ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/src/loader/loader.js#L32-L55
train
melonjs/melonJS
src/loader/loader.js
preloadFontFace
function preloadFontFace(data, onload, onerror) { var font = new FontFace(data.name, data.src); // loading promise font.load().then(function() { // apply the font after the font has finished downloading document.fonts.add(font); documen...
javascript
function preloadFontFace(data, onload, onerror) { var font = new FontFace(data.name, data.src); // loading promise font.load().then(function() { // apply the font after the font has finished downloading document.fonts.add(font); documen...
[ "function", "preloadFontFace", "(", "data", ",", "onload", ",", "onerror", ")", "{", "var", "font", "=", "new", "FontFace", "(", "data", ".", "name", ",", "data", ".", "src", ")", ";", "// loading promise", "font", ".", "load", "(", ")", ".", "then", ...
load a font face @example preloadFontFace( name: "'kenpixel'", type: "fontface", src: "url('data/font/kenvector_future.woff2')" ]); @ignore
[ "load", "a", "font", "face" ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/src/loader/loader.js#L87-L100
train
melonjs/melonJS
src/loader/loader.js
preloadJSON
function preloadJSON(data, onload, onerror) { var xmlhttp = new XMLHttpRequest(); if (xmlhttp.overrideMimeType) { xmlhttp.overrideMimeType("application/json"); } xmlhttp.open("GET", data.src + api.nocache, true); xmlhttp.withCredentials = me....
javascript
function preloadJSON(data, onload, onerror) { var xmlhttp = new XMLHttpRequest(); if (xmlhttp.overrideMimeType) { xmlhttp.overrideMimeType("application/json"); } xmlhttp.open("GET", data.src + api.nocache, true); xmlhttp.withCredentials = me....
[ "function", "preloadJSON", "(", "data", ",", "onload", ",", "onerror", ")", "{", "var", "xmlhttp", "=", "new", "XMLHttpRequest", "(", ")", ";", "if", "(", "xmlhttp", ".", "overrideMimeType", ")", "{", "xmlhttp", ".", "overrideMimeType", "(", "\"application/j...
preload JSON files @ignore
[ "preload", "JSON", "files" ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/src/loader/loader.js#L207-L236
train
melonjs/melonJS
src/shapes/poly.js
function (x, y, points) { this.pos.set(x, y); if (!Array.isArray(points)) { return this; } // convert given points to me.Vector2d if required if (!(points[0] instanceof me.Vector2d)) { var _points = this.points = []; ...
javascript
function (x, y, points) { this.pos.set(x, y); if (!Array.isArray(points)) { return this; } // convert given points to me.Vector2d if required if (!(points[0] instanceof me.Vector2d)) { var _points = this.points = []; ...
[ "function", "(", "x", ",", "y", ",", "points", ")", "{", "this", ".", "pos", ".", "set", "(", "x", ",", "y", ")", ";", "if", "(", "!", "Array", ".", "isArray", "(", "points", ")", ")", "{", "return", "this", ";", "}", "// convert given points to ...
set new value to the Polygon @name setShape @memberOf me.Polygon.prototype @function @param {Number} x position of the Polygon @param {Number} y position of the Polygon @param {me.Vector2d[]} points array of vector defining the Polygon
[ "set", "new", "value", "to", "the", "Polygon" ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/src/shapes/poly.js#L94-L116
train
melonjs/melonJS
src/shapes/poly.js
function (x, y) { y = typeof (y) !== "undefined" ? y : x; var points = this.points; var len = points.length; for (var i = 0; i < len; i++) { points[i].scale(x, y); } this.recalc(); this.updateBounds(); retur...
javascript
function (x, y) { y = typeof (y) !== "undefined" ? y : x; var points = this.points; var len = points.length; for (var i = 0; i < len; i++) { points[i].scale(x, y); } this.recalc(); this.updateBounds(); retur...
[ "function", "(", "x", ",", "y", ")", "{", "y", "=", "typeof", "(", "y", ")", "!==", "\"undefined\"", "?", "y", ":", "x", ";", "var", "points", "=", "this", ".", "points", ";", "var", "len", "=", "points", ".", "length", ";", "for", "(", "var", ...
Scale this Polygon by the given scalar. @name scale @memberOf me.Polygon.prototype @function @param {Number} x @param {Number} [y=x] @return {me.Polygon} Reference to this object for method chaining
[ "Scale", "this", "Polygon", "by", "the", "given", "scalar", "." ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/src/shapes/poly.js#L189-L200
train
melonjs/melonJS
src/entity/entity.js
function (body) { // update the entity bounds to match with the body bounds this.getBounds().resize(body.width, body.height); // update the bounds pos this.updateBoundsPos(this.pos.x, this.pos.y); }
javascript
function (body) { // update the entity bounds to match with the body bounds this.getBounds().resize(body.width, body.height); // update the bounds pos this.updateBoundsPos(this.pos.x, this.pos.y); }
[ "function", "(", "body", ")", "{", "// update the entity bounds to match with the body bounds", "this", ".", "getBounds", "(", ")", ".", "resize", "(", "body", ".", "width", ",", "body", ".", "height", ")", ";", "// update the bounds pos", "this", ".", "updateBoun...
update the bounds position when the body is modified @private @name onBodyUpdate @memberOf me.Entity @function
[ "update", "the", "bounds", "position", "when", "the", "body", "is", "modified" ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/src/entity/entity.js#L176-L181
train
melonjs/melonJS
src/shapes/rectangle.js
function () { return (isFinite(this.pos.x) && isFinite(this.pos.y) && isFinite(this._width) && isFinite(this._height)); }
javascript
function () { return (isFinite(this.pos.x) && isFinite(this.pos.y) && isFinite(this._width) && isFinite(this._height)); }
[ "function", "(", ")", "{", "return", "(", "isFinite", "(", "this", ".", "pos", ".", "x", ")", "&&", "isFinite", "(", "this", ".", "pos", ".", "y", ")", "&&", "isFinite", "(", "this", ".", "_width", ")", "&&", "isFinite", "(", "this", ".", "_heigh...
determines whether all coordinates of this rectangle are finite numbers. @name isFinite @memberOf me.Rect.prototype @function @return {boolean} false if all coordinates are positive or negative Infinity or NaN; otherwise, true.
[ "determines", "whether", "all", "coordinates", "of", "this", "rectangle", "are", "finite", "numbers", "." ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/src/shapes/rectangle.js#L283-L285
train
melonjs/melonJS
src/level/LevelDirector.js
loadTMXLevel
function loadTMXLevel(levelId, container, flatten, setViewportBounds) { var level = levels[levelId]; // disable auto-sort for the given container var autoSort = container.autoSort; container.autoSort = false; var levelBounds = level.getBounds(); ...
javascript
function loadTMXLevel(levelId, container, flatten, setViewportBounds) { var level = levels[levelId]; // disable auto-sort for the given container var autoSort = container.autoSort; container.autoSort = false; var levelBounds = level.getBounds(); ...
[ "function", "loadTMXLevel", "(", "levelId", ",", "container", ",", "flatten", ",", "setViewportBounds", ")", "{", "var", "level", "=", "levels", "[", "levelId", "]", ";", "// disable auto-sort for the given container", "var", "autoSort", "=", "container", ".", "au...
Load a TMX level @name loadTMXLevel @memberOf me.game @private @param {String} level level id @param {me.Container} target container @param {boolean} flatten if true, flatten all objects into the given container @param {boolean} setViewportBounds if true, set the viewport bounds to the map size @ignore @function
[ "Load", "a", "TMX", "level" ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/src/level/LevelDirector.js#L68-L120
train
melonjs/melonJS
src/shapes/line.js
function (x, y) { // translate the given coordinates, // rather than creating temp translated vectors x -= this.pos.x; // Cx y -= this.pos.y; // Cy var start = this.points[0]; // Ax/Ay var end = this.points[1]; // Bx/By //(Cy - Ay) * (...
javascript
function (x, y) { // translate the given coordinates, // rather than creating temp translated vectors x -= this.pos.x; // Cx y -= this.pos.y; // Cy var start = this.points[0]; // Ax/Ay var end = this.points[1]; // Bx/By //(Cy - Ay) * (...
[ "function", "(", "x", ",", "y", ")", "{", "// translate the given coordinates,", "// rather than creating temp translated vectors", "x", "-=", "this", ".", "pos", ".", "x", ";", "// Cx", "y", "-=", "this", ".", "pos", ".", "y", ";", "// Cy", "var", "start", ...
check if this line segment contains the specified point @name containsPoint @memberOf me.Line.prototype @function @param {Number} x x coordinate @param {Number} y y coordinate @return {boolean} true if contains
[ "check", "if", "this", "line", "segment", "contains", "the", "specified", "point" ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/src/shapes/line.js#L35-L45
train
melonjs/melonJS
src/font/text.js
function(context, font, stroke) { context.font = font.font; context.fillStyle = font.fillStyle.toRGBA(); if (stroke === true) { context.strokeStyle = font.strokeStyle.toRGBA(); context.lineWidth = font.lineWidth; } context.textAlign = font.textAlign; ...
javascript
function(context, font, stroke) { context.font = font.font; context.fillStyle = font.fillStyle.toRGBA(); if (stroke === true) { context.strokeStyle = font.strokeStyle.toRGBA(); context.lineWidth = font.lineWidth; } context.textAlign = font.textAlign; ...
[ "function", "(", "context", ",", "font", ",", "stroke", ")", "{", "context", ".", "font", "=", "font", ".", "font", ";", "context", ".", "fillStyle", "=", "font", ".", "fillStyle", ".", "toRGBA", "(", ")", ";", "if", "(", "stroke", "===", "true", "...
apply the current font style to the given context @ignore
[ "apply", "the", "current", "font", "style", "to", "the", "given", "context" ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/src/font/text.js#L17-L26
train
melonjs/melonJS
src/font/text.js
function (renderer, text, x, y, stroke) { // "hacky patch" for backward compatibilty if (typeof this.ancestor === "undefined") { // update text cache this.setText(text); // update position if changed if (this.pos.x !== x || this.po...
javascript
function (renderer, text, x, y, stroke) { // "hacky patch" for backward compatibilty if (typeof this.ancestor === "undefined") { // update text cache this.setText(text); // update position if changed if (this.pos.x !== x || this.po...
[ "function", "(", "renderer", ",", "text", ",", "x", ",", "y", ",", "stroke", ")", "{", "// \"hacky patch\" for backward compatibilty", "if", "(", "typeof", "this", ".", "ancestor", "===", "\"undefined\"", ")", "{", "// update text cache", "this", ".", "setText",...
draw a text at the specified coord @name draw @memberOf me.Text.prototype @function @param {me.CanvasRenderer|me.WebGLRenderer} renderer Reference to the destination renderer instance @param {String} [text] @param {Number} [x] @param {Number} [y]
[ "draw", "a", "text", "at", "the", "specified", "coord" ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/src/font/text.js#L332-L377
train
melonjs/melonJS
src/renderable/GUI.js
function (event) { // Check if left mouse button is pressed if (event.button === 0 && this.isClickable) { this.updated = true; this.released = false; if (this.isHoldable) { if (this.holdTimeout !== null) { ...
javascript
function (event) { // Check if left mouse button is pressed if (event.button === 0 && this.isClickable) { this.updated = true; this.released = false; if (this.isHoldable) { if (this.holdTimeout !== null) { ...
[ "function", "(", "event", ")", "{", "// Check if left mouse button is pressed", "if", "(", "event", ".", "button", "===", "0", "&&", "this", ".", "isClickable", ")", "{", "this", ".", "updated", "=", "true", ";", "this", ".", "released", "=", "false", ";",...
function callback for the pointerdown event @ignore
[ "function", "callback", "for", "the", "pointerdown", "event" ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/src/renderable/GUI.js#L124-L138
train
melonjs/melonJS
src/renderable/GUI.js
function (event) { if (this.released === false) { this.released = true; me.timer.clearTimeout(this.holdTimeout); return this.onRelease.call(this, event); } }
javascript
function (event) { if (this.released === false) { this.released = true; me.timer.clearTimeout(this.holdTimeout); return this.onRelease.call(this, event); } }
[ "function", "(", "event", ")", "{", "if", "(", "this", ".", "released", "===", "false", ")", "{", "this", ".", "released", "=", "true", ";", "me", ".", "timer", ".", "clearTimeout", "(", "this", ".", "holdTimeout", ")", ";", "return", "this", ".", ...
function callback for the pointerup event @ignore
[ "function", "callback", "for", "the", "pointerup", "event" ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/src/renderable/GUI.js#L197-L203
train
melonjs/melonJS
src/particles/emitter.js
function (count) { for (var i = 0; i < ~~count; i++) { // Add particle to the container var particle = me.pool.pull("me.Particle", this); this.container.addChild(particle); } }
javascript
function (count) { for (var i = 0; i < ~~count; i++) { // Add particle to the container var particle = me.pool.pull("me.Particle", this); this.container.addChild(particle); } }
[ "function", "(", "count", ")", "{", "for", "(", "var", "i", "=", "0", ";", "i", "<", "~", "~", "count", ";", "i", "++", ")", "{", "// Add particle to the container", "var", "particle", "=", "me", ".", "pool", ".", "pull", "(", "\"me.Particle\"", ",",...
Add count particles in the game world @ignore
[ "Add", "count", "particles", "in", "the", "game", "world" ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/src/particles/emitter.js#L473-L479
train
melonjs/melonJS
dist/melonjs.js
apply_methods
function apply_methods(Class, methods, descriptor) { Object.keys(descriptor).forEach(function (method) { methods[method] = descriptor[method]; if (typeof(descriptor[method]) !== "function") { throw new TypeError( "extend: Method `" + me...
javascript
function apply_methods(Class, methods, descriptor) { Object.keys(descriptor).forEach(function (method) { methods[method] = descriptor[method]; if (typeof(descriptor[method]) !== "function") { throw new TypeError( "extend: Method `" + me...
[ "function", "apply_methods", "(", "Class", ",", "methods", ",", "descriptor", ")", "{", "Object", ".", "keys", "(", "descriptor", ")", ".", "forEach", "(", "function", "(", "method", ")", "{", "methods", "[", "method", "]", "=", "descriptor", "[", "metho...
Apply methods to the class prototype. @ignore
[ "Apply", "methods", "to", "the", "class", "prototype", "." ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/dist/melonjs.js#L233-L248
train
melonjs/melonJS
dist/melonjs.js
angle
function angle(v) { return Math.acos(me.Math.clamp(this.dotProduct(v) / (this.length() * v.length()), -1, 1)); }
javascript
function angle(v) { return Math.acos(me.Math.clamp(this.dotProduct(v) / (this.length() * v.length()), -1, 1)); }
[ "function", "angle", "(", "v", ")", "{", "return", "Math", ".", "acos", "(", "me", ".", "Math", ".", "clamp", "(", "this", ".", "dotProduct", "(", "v", ")", "/", "(", "this", ".", "length", "(", ")", "*", "v", ".", "length", "(", ")", ")", ",...
return the angle between this vector and the passed one @name angle @memberOf me.Vector2d @function @param {me.Vector2d} v @return {Number} angle in radians
[ "return", "the", "angle", "between", "this", "vector", "and", "the", "passed", "one" ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/dist/melonjs.js#L3697-L3699
train
melonjs/melonJS
dist/melonjs.js
floorSelf
function floorSelf() { return this._set(Math.floor(this.x), Math.floor(this.y), Math.floor(this.z)); }
javascript
function floorSelf() { return this._set(Math.floor(this.x), Math.floor(this.y), Math.floor(this.z)); }
[ "function", "floorSelf", "(", ")", "{", "return", "this", ".", "_set", "(", "Math", ".", "floor", "(", "this", ".", "x", ")", ",", "Math", ".", "floor", "(", "this", ".", "y", ")", ",", "Math", ".", "floor", "(", "this", ".", "z", ")", ")", "...
Floor this vector values @name floorSelf @memberOf me.Vector3d @function @return {me.Vector3d} Reference to this object for method chaining
[ "Floor", "this", "vector", "values" ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/dist/melonjs.js#L4015-L4017
train
melonjs/melonJS
dist/melonjs.js
ceil
function ceil() { return new me.Vector3d(Math.ceil(this.x), Math.ceil(this.y), Math.ceil(this.z)); }
javascript
function ceil() { return new me.Vector3d(Math.ceil(this.x), Math.ceil(this.y), Math.ceil(this.z)); }
[ "function", "ceil", "(", ")", "{", "return", "new", "me", ".", "Vector3d", "(", "Math", ".", "ceil", "(", "this", ".", "x", ")", ",", "Math", ".", "ceil", "(", "this", ".", "y", ")", ",", "Math", ".", "ceil", "(", "this", ".", "z", ")", ")", ...
Ceil the vector values @name ceil @memberOf me.Vector3d @function @return {me.Vector3d} new me.Vector3d
[ "Ceil", "the", "vector", "values" ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/dist/melonjs.js#L4026-L4028
train
melonjs/melonJS
dist/melonjs.js
ceilSelf
function ceilSelf() { return this._set(Math.ceil(this.x), Math.ceil(this.y), Math.ceil(this.z)); }
javascript
function ceilSelf() { return this._set(Math.ceil(this.x), Math.ceil(this.y), Math.ceil(this.z)); }
[ "function", "ceilSelf", "(", ")", "{", "return", "this", ".", "_set", "(", "Math", ".", "ceil", "(", "this", ".", "x", ")", ",", "Math", ".", "ceil", "(", "this", ".", "y", ")", ",", "Math", ".", "ceil", "(", "this", ".", "z", ")", ")", ";", ...
Ceil this vector values @name ceilSelf @memberOf me.Vector3d @function @return {me.Vector3d} Reference to this object for method chaining
[ "Ceil", "this", "vector", "values" ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/dist/melonjs.js#L4037-L4039
train
melonjs/melonJS
dist/melonjs.js
setMuted
function setMuted(x, y, z) { this._x = x; this._y = y; this._z = z; return this; }
javascript
function setMuted(x, y, z) { this._x = x; this._y = y; this._z = z; return this; }
[ "function", "setMuted", "(", "x", ",", "y", ",", "z", ")", "{", "this", ".", "_x", "=", "x", ";", "this", ".", "_y", "=", "y", ";", "this", ".", "_z", "=", "z", ";", "return", "this", ";", "}" ]
set the vector value without triggering the callback @name setMuted @memberOf me.ObservableVector3d @function @param {Number} x x value of the vector @param {Number} y y value of the vector @param {Number} z z value of the vector @return {me.ObservableVector3d} Reference to this object for method chaining
[ "set", "the", "vector", "value", "without", "triggering", "the", "callback" ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/dist/melonjs.js#L4872-L4877
train
melonjs/melonJS
dist/melonjs.js
add
function add(v) { return this._set(this._x + v.x, this._y + v.y, this._z + (v.z || 0)); }
javascript
function add(v) { return this._set(this._x + v.x, this._y + v.y, this._z + (v.z || 0)); }
[ "function", "add", "(", "v", ")", "{", "return", "this", ".", "_set", "(", "this", ".", "_x", "+", "v", ".", "x", ",", "this", ".", "_y", "+", "v", ".", "y", ",", "this", ".", "_z", "+", "(", "v", ".", "z", "||", "0", ")", ")", ";", "}"...
Add the passed vector to this vector @name add @memberOf me.ObservableVector3d @function @param {me.Vector2d|me.Vector3d|me.ObservableVector2d|me.ObservableVector3d} v @return {me.ObservableVector3d} Reference to this object for method chaining
[ "Add", "the", "passed", "vector", "to", "this", "vector" ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/dist/melonjs.js#L4904-L4906
train
melonjs/melonJS
dist/melonjs.js
equals
function equals(v) { return this._x === v.x && this._y === v.y && this._z === (v.z || this._z); }
javascript
function equals(v) { return this._x === v.x && this._y === v.y && this._z === (v.z || this._z); }
[ "function", "equals", "(", "v", ")", "{", "return", "this", ".", "_x", "===", "v", ".", "x", "&&", "this", ".", "_y", "===", "v", ".", "y", "&&", "this", ".", "_z", "===", "(", "v", ".", "z", "||", "this", ".", "_z", ")", ";", "}" ]
return true if the two vectors are the same @name equals @memberOf me.ObservableVector3d @function @param {me.Vector2d|me.Vector3d|me.ObservableVector2d|me.ObservableVector3d} v @return {Boolean}
[ "return", "true", "if", "the", "two", "vectors", "are", "the", "same" ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/dist/melonjs.js#L5119-L5121
train
melonjs/melonJS
dist/melonjs.js
dotProduct
function dotProduct(v) { return this._x * v.x + this._y * v.y + this._z * (v.z || 1); }
javascript
function dotProduct(v) { return this._x * v.x + this._y * v.y + this._z * (v.z || 1); }
[ "function", "dotProduct", "(", "v", ")", "{", "return", "this", ".", "_x", "*", "v", ".", "x", "+", "this", ".", "_y", "*", "v", ".", "y", "+", "this", ".", "_z", "*", "(", "v", ".", "z", "||", "1", ")", ";", "}" ]
return the dot product of this vector and the passed one @name dotProduct @memberOf me.ObservableVector3d @function @param {me.Vector2d|me.Vector3d|me.ObservableVector2d|me.ObservableVector3d} v @return {Number} The dot product.
[ "return", "the", "dot", "product", "of", "this", "vector", "and", "the", "passed", "one" ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/dist/melonjs.js#L5174-L5176
train
melonjs/melonJS
dist/melonjs.js
setTransform
function setTransform() { var a = this.val; if (arguments.length === 9) { a[0] = arguments[0]; // a - m00 a[1] = arguments[1]; // b - m10 a[2] = arguments[2]; // c - m20 a[3] = arguments[3]; // d - m01 a[4] = arguments[4]; // e - m11 ...
javascript
function setTransform() { var a = this.val; if (arguments.length === 9) { a[0] = arguments[0]; // a - m00 a[1] = arguments[1]; // b - m10 a[2] = arguments[2]; // c - m20 a[3] = arguments[3]; // d - m01 a[4] = arguments[4]; // e - m11 ...
[ "function", "setTransform", "(", ")", "{", "var", "a", "=", "this", ".", "val", ";", "if", "(", "arguments", ".", "length", "===", "9", ")", "{", "a", "[", "0", "]", "=", "arguments", "[", "0", "]", ";", "// a - m00", "a", "[", "1", "]", "=", ...
set the matrix to the specified value @name setTransform @memberOf me.Matrix2d @function @param {Number} a @param {Number} b @param {Number} c @param {Number} d @param {Number} e @param {Number} f @param {Number} [g=0] @param {Number} [h=0] @param {Number} [i=1] @return {me.Matrix2d} Reference to this object for method...
[ "set", "the", "matrix", "to", "the", "specified", "value" ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/dist/melonjs.js#L5306-L5348
train
melonjs/melonJS
dist/melonjs.js
multiplyVectorInverse
function multiplyVectorInverse(v) { var a = this.val, x = v.x, y = v.y; var invD = 1 / (a[0] * a[4] + a[3] * -a[1]); v.x = a[4] * invD * x + -a[3] * invD * y + (a[7] * a[3] - a[6] * a[4]) * invD; v.y = a[0] * invD * y + -a[1] * invD * x + (-a[7] * a[0] + a[6...
javascript
function multiplyVectorInverse(v) { var a = this.val, x = v.x, y = v.y; var invD = 1 / (a[0] * a[4] + a[3] * -a[1]); v.x = a[4] * invD * x + -a[3] * invD * y + (a[7] * a[3] - a[6] * a[4]) * invD; v.y = a[0] * invD * y + -a[1] * invD * x + (-a[7] * a[0] + a[6...
[ "function", "multiplyVectorInverse", "(", "v", ")", "{", "var", "a", "=", "this", ".", "val", ",", "x", "=", "v", ".", "x", ",", "y", "=", "v", ".", "y", ";", "var", "invD", "=", "1", "/", "(", "a", "[", "0", "]", "*", "a", "[", "4", "]",...
Transforms the given vector using the inverted current matrix. @name multiplyVector @memberOf me.Matrix2d @function @param {me.Vector2d} vector the vector object to be transformed @return {me.Vector2d} result vector object. Useful for chaining method calls.
[ "Transforms", "the", "given", "vector", "using", "the", "inverted", "current", "matrix", "." ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/dist/melonjs.js#L5474-L5482
train
melonjs/melonJS
dist/melonjs.js
setShape
function setShape(x, y, w, h) { var hW = w / 2; var hH = h / 2; this.pos.set(x, y); this.radius = Math.max(hW, hH); this.ratio.set(hW / this.radius, hH / this.radius); this.radiusV.set(this.radius, this.radius).scaleV(this.ratio); var r = this.radius * this...
javascript
function setShape(x, y, w, h) { var hW = w / 2; var hH = h / 2; this.pos.set(x, y); this.radius = Math.max(hW, hH); this.ratio.set(hW / this.radius, hH / this.radius); this.radiusV.set(this.radius, this.radius).scaleV(this.ratio); var r = this.radius * this...
[ "function", "setShape", "(", "x", ",", "y", ",", "w", ",", "h", ")", "{", "var", "hW", "=", "w", "/", "2", ";", "var", "hH", "=", "h", "/", "2", ";", "this", ".", "pos", ".", "set", "(", "x", ",", "y", ")", ";", "this", ".", "radius", "...
set new value to the Ellipse shape @name setShape @memberOf me.Ellipse.prototype @function @param {Number} x position of the ellipse @param {Number} y position of the ellipse @param {Number} w width (diameter) of the ellipse @param {Number} h height (diameter) of the ellipse
[ "set", "new", "value", "to", "the", "Ellipse", "shape" ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/dist/melonjs.js#L5760-L5771
train
melonjs/melonJS
dist/melonjs.js
scale
function scale(x, y) { y = typeof y !== "undefined" ? y : x; return this.setShape(this.pos.x, this.pos.y, this.radiusV.x * 2 * x, this.radiusV.y * 2 * y); }
javascript
function scale(x, y) { y = typeof y !== "undefined" ? y : x; return this.setShape(this.pos.x, this.pos.y, this.radiusV.x * 2 * x, this.radiusV.y * 2 * y); }
[ "function", "scale", "(", "x", ",", "y", ")", "{", "y", "=", "typeof", "y", "!==", "\"undefined\"", "?", "y", ":", "x", ";", "return", "this", ".", "setShape", "(", "this", ".", "pos", ".", "x", ",", "this", ".", "pos", ".", "y", ",", "this", ...
Scale this Ellipse by the specified scalar. @name scale @memberOf me.Ellipse.prototype @function @param {Number} x @param {Number} [y=x] @return {me.Ellipse} Reference to this object for method chaining
[ "Scale", "this", "Ellipse", "by", "the", "specified", "scalar", "." ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/dist/melonjs.js#L5797-L5800
train
melonjs/melonJS
dist/melonjs.js
splitEarcut
function splitEarcut(start, triangles, dim, minX, minY, invSize) { // look for a valid diagonal that divides the polygon into two var a = start; do { var b = a.next.next; while (b !== a.prev) { if (a.i !== b.i && isValidDiagonal(a, b)) { // sp...
javascript
function splitEarcut(start, triangles, dim, minX, minY, invSize) { // look for a valid diagonal that divides the polygon into two var a = start; do { var b = a.next.next; while (b !== a.prev) { if (a.i !== b.i && isValidDiagonal(a, b)) { // sp...
[ "function", "splitEarcut", "(", "start", ",", "triangles", ",", "dim", ",", "minX", ",", "minY", ",", "invSize", ")", "{", "// look for a valid diagonal that divides the polygon into two", "var", "a", "=", "start", ";", "do", "{", "var", "b", "=", "a", ".", ...
try splitting polygon into two and triangulate them independently
[ "try", "splitting", "polygon", "into", "two", "and", "triangulate", "them", "independently" ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/dist/melonjs.js#L6175-L6198
train
melonjs/melonJS
dist/melonjs.js
zOrder
function zOrder(x, y, minX, minY, invSize) { // coords are transformed into non-negative 15-bit integer range x = 32767 * (x - minX) * invSize; y = 32767 * (y - minY) * invSize; x = (x | (x << 8)) & 0x00FF00FF; x = (x | (x << 4)) & 0x0F0F0F0F; x = (x | (x << 2)) & 0x33333333; ...
javascript
function zOrder(x, y, minX, minY, invSize) { // coords are transformed into non-negative 15-bit integer range x = 32767 * (x - minX) * invSize; y = 32767 * (y - minY) * invSize; x = (x | (x << 8)) & 0x00FF00FF; x = (x | (x << 4)) & 0x0F0F0F0F; x = (x | (x << 2)) & 0x33333333; ...
[ "function", "zOrder", "(", "x", ",", "y", ",", "minX", ",", "minY", ",", "invSize", ")", "{", "// coords are transformed into non-negative 15-bit integer range", "x", "=", "32767", "*", "(", "x", "-", "minX", ")", "*", "invSize", ";", "y", "=", "32767", "*...
z-order of a point given coords and inverse of the longer side of data bbox
[ "z", "-", "order", "of", "a", "point", "given", "coords", "and", "inverse", "of", "the", "longer", "side", "of", "data", "bbox" ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/dist/melonjs.js#L6366-L6382
train
melonjs/melonJS
dist/melonjs.js
pointInTriangle
function pointInTriangle(ax, ay, bx, by, cx, cy, px, py) { return (cx - px) * (ay - py) - (ax - px) * (cy - py) >= 0 && (ax - px) * (by - py) - (bx - px) * (ay - py) >= 0 && (bx - px) * (cy - py) - (cx - px) * (by - py) >= 0; }
javascript
function pointInTriangle(ax, ay, bx, by, cx, cy, px, py) { return (cx - px) * (ay - py) - (ax - px) * (cy - py) >= 0 && (ax - px) * (by - py) - (bx - px) * (ay - py) >= 0 && (bx - px) * (cy - py) - (cx - px) * (by - py) >= 0; }
[ "function", "pointInTriangle", "(", "ax", ",", "ay", ",", "bx", ",", "by", ",", "cx", ",", "cy", ",", "px", ",", "py", ")", "{", "return", "(", "cx", "-", "px", ")", "*", "(", "ay", "-", "py", ")", "-", "(", "ax", "-", "px", ")", "*", "("...
check if a point lies within a convex triangle
[ "check", "if", "a", "point", "lies", "within", "a", "convex", "triangle" ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/dist/melonjs.js#L6397-L6401
train
melonjs/melonJS
dist/melonjs.js
area
function area(p, q, r) { return (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y); }
javascript
function area(p, q, r) { return (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y); }
[ "function", "area", "(", "p", ",", "q", ",", "r", ")", "{", "return", "(", "q", ".", "y", "-", "p", ".", "y", ")", "*", "(", "r", ".", "x", "-", "q", ".", "x", ")", "-", "(", "q", ".", "x", "-", "p", ".", "x", ")", "*", "(", "r", ...
signed area of a triangle
[ "signed", "area", "of", "a", "triangle" ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/dist/melonjs.js#L6410-L6412
train
melonjs/melonJS
dist/melonjs.js
splitPolygon
function splitPolygon(a, b) { var a2 = new Node(a.i, a.x, a.y), b2 = new Node(b.i, b.x, b.y), an = a.next, bp = b.prev; a.next = b; b.prev = a; a2.next = an; an.prev = a2; b2.next = a2; a2.prev = b2; bp.next = b2; b2.pre...
javascript
function splitPolygon(a, b) { var a2 = new Node(a.i, a.x, a.y), b2 = new Node(b.i, b.x, b.y), an = a.next, bp = b.prev; a.next = b; b.prev = a; a2.next = an; an.prev = a2; b2.next = a2; a2.prev = b2; bp.next = b2; b2.pre...
[ "function", "splitPolygon", "(", "a", ",", "b", ")", "{", "var", "a2", "=", "new", "Node", "(", "a", ".", "i", ",", "a", ".", "x", ",", "a", ".", "y", ")", ",", "b2", "=", "new", "Node", "(", "b", ".", "i", ",", "b", ".", "x", ",", "b",...
link two polygon vertices with a bridge; if the vertices belong to the same ring, it splits polygon into two; if one belongs to the outer ring and another to a hole, it merges it into a single ring
[ "link", "two", "polygon", "vertices", "with", "a", "bridge", ";", "if", "the", "vertices", "belong", "to", "the", "same", "ring", "it", "splits", "polygon", "into", "two", ";", "if", "one", "belongs", "to", "the", "outer", "ring", "and", "another", "to",...
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/dist/melonjs.js#L6464-L6483
train
melonjs/melonJS
dist/melonjs.js
transform
function transform(m) { var points = this.points; var len = points.length; for (var i = 0; i < len; i++) { m.multiplyVector(points[i]); } this.recalc(); this.updateBounds(); return this; }
javascript
function transform(m) { var points = this.points; var len = points.length; for (var i = 0; i < len; i++) { m.multiplyVector(points[i]); } this.recalc(); this.updateBounds(); return this; }
[ "function", "transform", "(", "m", ")", "{", "var", "points", "=", "this", ".", "points", ";", "var", "len", "=", "points", ".", "length", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "len", ";", "i", "++", ")", "{", "m", ".", "multi...
apply the given transformation matrix to this Polygon @name transform @memberOf me.Polygon.prototype @function @param {me.Matrix2d} matrix the transformation matrix @return {me.Polygon} Reference to this object for method chaining
[ "apply", "the", "given", "transformation", "matrix", "to", "this", "Polygon" ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/dist/melonjs.js#L6713-L6724
train
melonjs/melonJS
dist/melonjs.js
clone
function clone() { var copy = []; this.points.forEach(function (point) { copy.push(point.clone()); }); return new me.Polygon(this.pos.x, this.pos.y, copy); }
javascript
function clone() { var copy = []; this.points.forEach(function (point) { copy.push(point.clone()); }); return new me.Polygon(this.pos.x, this.pos.y, copy); }
[ "function", "clone", "(", ")", "{", "var", "copy", "=", "[", "]", ";", "this", ".", "points", ".", "forEach", "(", "function", "(", "point", ")", "{", "copy", ".", "push", "(", "point", ".", "clone", "(", ")", ")", ";", "}", ")", ";", "return",...
clone this Polygon @name clone @memberOf me.Polygon.prototype @function @return {me.Polygon} new Polygon
[ "clone", "this", "Polygon" ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/dist/melonjs.js#L6992-L6998
train
melonjs/melonJS
dist/melonjs.js
setShape
function setShape(x, y, w, h) { var points = w; // assume w is an array by default if (arguments.length === 4) { points = this.points; points[0].set(0, 0); // 0, 0 points[1].set(w, 0); // 1, 0 points[2].set(w, h); // 1, 1 points[3].set(0, h); ...
javascript
function setShape(x, y, w, h) { var points = w; // assume w is an array by default if (arguments.length === 4) { points = this.points; points[0].set(0, 0); // 0, 0 points[1].set(w, 0); // 1, 0 points[2].set(w, h); // 1, 1 points[3].set(0, h); ...
[ "function", "setShape", "(", "x", ",", "y", ",", "w", ",", "h", ")", "{", "var", "points", "=", "w", ";", "// assume w is an array by default", "if", "(", "arguments", ".", "length", "===", "4", ")", "{", "points", "=", "this", ".", "points", ";", "p...
set new value to the rectangle shape @name setShape @memberOf me.Rect.prototype @function @param {Number} x position of the Rectangle @param {Number} y position of the Rectangle @param {Number|Array} w|points width of the rectangle, or an array of vector defining the rectangle @param {Number} [h] height of the rectangl...
[ "set", "new", "value", "to", "the", "rectangle", "shape" ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/dist/melonjs.js#L7044-L7066
train
melonjs/melonJS
dist/melonjs.js
setPoints
function setPoints(points) { var x = Infinity, y = Infinity, right = -Infinity, bottom = -Infinity; points.forEach(function (point) { x = Math.min(x, point.x); y = Math.min(y, point.y); right = Math.max(right, point.x); ...
javascript
function setPoints(points) { var x = Infinity, y = Infinity, right = -Infinity, bottom = -Infinity; points.forEach(function (point) { x = Math.min(x, point.x); y = Math.min(y, point.y); right = Math.max(right, point.x); ...
[ "function", "setPoints", "(", "points", ")", "{", "var", "x", "=", "Infinity", ",", "y", "=", "Infinity", ",", "right", "=", "-", "Infinity", ",", "bottom", "=", "-", "Infinity", ";", "points", ".", "forEach", "(", "function", "(", "point", ")", "{",...
resize the rectangle to contain all the given points coordinates. @name setPoints @memberOf me.Rect.prototype @function @param {me.Vector2d[]} points array of vector defining a shape @return {me.Rect} this shape bounding box Rectangle object
[ "resize", "the", "rectangle", "to", "contain", "all", "the", "given", "points", "coordinates", "." ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/dist/melonjs.js#L7102-L7115
train
melonjs/melonJS
dist/melonjs.js
copy
function copy(rect) { return this.setShape(rect.pos.x, rect.pos.y, rect._width, rect._height); }
javascript
function copy(rect) { return this.setShape(rect.pos.x, rect.pos.y, rect._width, rect._height); }
[ "function", "copy", "(", "rect", ")", "{", "return", "this", ".", "setShape", "(", "rect", ".", "pos", ".", "x", ",", "rect", ".", "pos", ".", "y", ",", "rect", ".", "_width", ",", "rect", ".", "_height", ")", ";", "}" ]
copy the position and size of the given rectangle into this one @name copy @memberOf me.Rect.prototype @function @param {me.Rect} rect Source rectangle @return {me.Rect} new rectangle
[ "copy", "the", "position", "and", "size", "of", "the", "given", "rectangle", "into", "this", "one" ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/dist/melonjs.js#L7163-L7165
train
melonjs/melonJS
dist/melonjs.js
union
function union( /** {me.Rect} */ r) { var x1 = Math.min(this.left, r.left); var y1 = Math.min(this.top, r.top); this.resize(Math.max(this.right, r.right) - x1, Math.max(this.bottom, r.bottom) - y1); this.pos.set(x1, y1); return this; }
javascript
function union( /** {me.Rect} */ r) { var x1 = Math.min(this.left, r.left); var y1 = Math.min(this.top, r.top); this.resize(Math.max(this.right, r.right) - x1, Math.max(this.bottom, r.bottom) - y1); this.pos.set(x1, y1); return this; }
[ "function", "union", "(", "/** {me.Rect} */", "r", ")", "{", "var", "x1", "=", "Math", ".", "min", "(", "this", ".", "left", ",", "r", ".", "left", ")", ";", "var", "y1", "=", "Math", ".", "min", "(", "this", ".", "top", ",", "r", ".", "top", ...
merge this rectangle with another one @name union @memberOf me.Rect.prototype @function @param {me.Rect} rect other rectangle to union with @return {me.Rect} the union(ed) rectangle
[ "merge", "this", "rectangle", "with", "another", "one" ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/dist/melonjs.js#L7202-L7210
train
melonjs/melonJS
dist/melonjs.js
containsPoint
function containsPoint(x, y) { return x >= this.left && x <= this.right && y >= this.top && y <= this.bottom; }
javascript
function containsPoint(x, y) { return x >= this.left && x <= this.right && y >= this.top && y <= this.bottom; }
[ "function", "containsPoint", "(", "x", ",", "y", ")", "{", "return", "x", ">=", "this", ".", "left", "&&", "x", "<=", "this", ".", "right", "&&", "y", ">=", "this", ".", "top", "&&", "y", "<=", "this", ".", "bottom", ";", "}" ]
check if this rectangle contains the specified point @name containsPoint @memberOf me.Rect.prototype @function @param {Number} x x coordinate @param {Number} y y coordinate @return {boolean} true if contains
[ "check", "if", "this", "rectangle", "contains", "the", "specified", "point" ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/dist/melonjs.js#L7245-L7247
train
melonjs/melonJS
dist/melonjs.js
equals
function equals(r) { return r.left === this.left && r.right === this.right && r.top === this.top && r.bottom === this.bottom; }
javascript
function equals(r) { return r.left === this.left && r.right === this.right && r.top === this.top && r.bottom === this.bottom; }
[ "function", "equals", "(", "r", ")", "{", "return", "r", ".", "left", "===", "this", ".", "left", "&&", "r", ".", "right", "===", "this", ".", "right", "&&", "r", ".", "top", "===", "this", ".", "top", "&&", "r", ".", "bottom", "===", "this", "...
check if this rectangle is identical to the specified one @name equals @memberOf me.Rect.prototype @function @param {me.Rect} rect @return {boolean} true if equals
[ "check", "if", "this", "rectangle", "is", "identical", "to", "the", "specified", "one" ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/dist/melonjs.js#L7257-L7259
train
melonjs/melonJS
dist/melonjs.js
removeShape
function removeShape(shape) { me.utils.array.remove(this.shapes, shape); // update the body bounds to take in account the removed shape this.updateBounds(); // return the length of the shape list return this.shapes.length; }
javascript
function removeShape(shape) { me.utils.array.remove(this.shapes, shape); // update the body bounds to take in account the removed shape this.updateBounds(); // return the length of the shape list return this.shapes.length; }
[ "function", "removeShape", "(", "shape", ")", "{", "me", ".", "utils", ".", "array", ".", "remove", "(", "this", ".", "shapes", ",", "shape", ")", ";", "// update the body bounds to take in account the removed shape", "this", ".", "updateBounds", "(", ")", ";", ...
remove the specified shape from the body shape list @name removeShape @memberOf me.Body @public @function @param {me.Polygon|me.Line|me.Ellipse} shape a shape object @return {Number} the shape array length
[ "remove", "the", "specified", "shape", "from", "the", "body", "shape", "list" ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/dist/melonjs.js#L7944-L7950
train
melonjs/melonJS
dist/melonjs.js
computeVelocity
function computeVelocity(vel) { // apply fore if defined if (this.force.x) { vel.x += this.force.x * me.timer.tick; } if (this.force.y) { vel.y += this.force.y * me.timer.tick; } // apply friction if (this.friction.x || this.friction.y) { ...
javascript
function computeVelocity(vel) { // apply fore if defined if (this.force.x) { vel.x += this.force.x * me.timer.tick; } if (this.force.y) { vel.y += this.force.y * me.timer.tick; } // apply friction if (this.friction.x || this.friction.y) { ...
[ "function", "computeVelocity", "(", "vel", ")", "{", "// apply fore if defined", "if", "(", "this", ".", "force", ".", "x", ")", "{", "vel", ".", "x", "+=", "this", ".", "force", ".", "x", "*", "me", ".", "timer", ".", "tick", ";", "}", "if", "(", ...
compute the new velocity value @ignore
[ "compute", "the", "new", "velocity", "value" ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/dist/melonjs.js#L8120-L8155
train
melonjs/melonJS
dist/melonjs.js
QT_ARRAY_POP
function QT_ARRAY_POP(bounds, max_objects, max_levels, level) { if (QT_ARRAY.length > 0) { var _qt = QT_ARRAY.pop(); _qt.bounds = bounds; _qt.max_objects = max_objects || 4; _qt.max_levels = max_levels || 4; _qt.level = level || 0; return _qt; } else ...
javascript
function QT_ARRAY_POP(bounds, max_objects, max_levels, level) { if (QT_ARRAY.length > 0) { var _qt = QT_ARRAY.pop(); _qt.bounds = bounds; _qt.max_objects = max_objects || 4; _qt.max_levels = max_levels || 4; _qt.level = level || 0; return _qt; } else ...
[ "function", "QT_ARRAY_POP", "(", "bounds", ",", "max_objects", ",", "max_levels", ",", "level", ")", "{", "if", "(", "QT_ARRAY", ".", "length", ">", "0", ")", "{", "var", "_qt", "=", "QT_ARRAY", ".", "pop", "(", ")", ";", "_qt", ".", "bounds", "=", ...
will pop a quadtree object from the array or create a new one if the array is empty
[ "will", "pop", "a", "quadtree", "object", "from", "the", "array", "or", "create", "a", "new", "one", "if", "the", "array", "is", "empty" ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/dist/melonjs.js#L8214-L8226
train
melonjs/melonJS
dist/melonjs.js
scale
function scale(x, y) { var _x = x, _y = typeof y === "undefined" ? _x : y; // set the scaleFlag this.currentTransform.scale(_x, _y); // resize the bounding box this.getBounds().resize(this.width * _x, this.height * _y); return this; }
javascript
function scale(x, y) { var _x = x, _y = typeof y === "undefined" ? _x : y; // set the scaleFlag this.currentTransform.scale(_x, _y); // resize the bounding box this.getBounds().resize(this.width * _x, this.height * _y); return this; }
[ "function", "scale", "(", "x", ",", "y", ")", "{", "var", "_x", "=", "x", ",", "_y", "=", "typeof", "y", "===", "\"undefined\"", "?", "_x", ":", "y", ";", "// set the scaleFlag", "this", ".", "currentTransform", ".", "scale", "(", "_x", ",", "_y", ...
scale the renderable around his anchor point. Scaling actually applies changes to the currentTransform member wich is used by the renderer to scale the object when rendering. It does not scale the object itself. For example if the renderable is an image, the image.width and image.height properties are unaltered but ...
[ "scale", "the", "renderable", "around", "his", "anchor", "point", ".", "Scaling", "actually", "applies", "changes", "to", "the", "currentTransform", "member", "wich", "is", "used", "by", "the", "renderer", "to", "scale", "the", "object", "when", "rendering", "...
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/dist/melonjs.js#L9890-L9899
train
melonjs/melonJS
dist/melonjs.js
resize
function resize(w, h) { this._super(me.Renderable, "resize", [this.repeatX ? Infinity : w, this.repeatY ? Infinity : h]); }
javascript
function resize(w, h) { this._super(me.Renderable, "resize", [this.repeatX ? Infinity : w, this.repeatY ? Infinity : h]); }
[ "function", "resize", "(", "w", ",", "h", ")", "{", "this", ".", "_super", "(", "me", ".", "Renderable", ",", "\"resize\"", ",", "[", "this", ".", "repeatX", "?", "Infinity", ":", "w", ",", "this", ".", "repeatY", "?", "Infinity", ":", "h", "]", ...
resize the Image Layer to match the given size @name resize @memberOf me.ImageLayer.prototype @function @param {Number} w new width @param {Number} h new height
[ "resize", "the", "Image", "Layer", "to", "match", "the", "given", "size" ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/dist/melonjs.js#L10448-L10450
train
melonjs/melonJS
dist/melonjs.js
onDeactivateEvent
function onDeactivateEvent() { // cancel all event subscriptions me.event.unsubscribe(this.vpChangeHdlr); me.event.unsubscribe(this.vpResizeHdlr); me.event.unsubscribe(this.vpLoadedHdlr); }
javascript
function onDeactivateEvent() { // cancel all event subscriptions me.event.unsubscribe(this.vpChangeHdlr); me.event.unsubscribe(this.vpResizeHdlr); me.event.unsubscribe(this.vpLoadedHdlr); }
[ "function", "onDeactivateEvent", "(", ")", "{", "// cancel all event subscriptions", "me", ".", "event", ".", "unsubscribe", "(", "this", ".", "vpChangeHdlr", ")", ";", "me", ".", "event", ".", "unsubscribe", "(", "this", ".", "vpResizeHdlr", ")", ";", "me", ...
called when the layer is removed from the game world or a container
[ "called", "when", "the", "layer", "is", "removed", "from", "the", "game", "world", "or", "a", "container" ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/dist/melonjs.js#L10542-L10547
train
melonjs/melonJS
dist/melonjs.js
reverseAnimation
function reverseAnimation(name) { if (typeof name !== "undefined" && typeof this.anim[name] !== "undefined") { this.anim[name].frames.reverse(); } else { this.anim[this.current.name].frames.reverse(); } return this; }
javascript
function reverseAnimation(name) { if (typeof name !== "undefined" && typeof this.anim[name] !== "undefined") { this.anim[name].frames.reverse(); } else { this.anim[this.current.name].frames.reverse(); } return this; }
[ "function", "reverseAnimation", "(", "name", ")", "{", "if", "(", "typeof", "name", "!==", "\"undefined\"", "&&", "typeof", "this", ".", "anim", "[", "name", "]", "!==", "\"undefined\"", ")", "{", "this", ".", "anim", "[", "name", "]", ".", "frames", "...
reverse the given or current animation if none is specified @name reverseAnimation @memberOf me.Sprite.prototype @function @param {String} [name] animation id @return {me.Sprite} Reference to this object for method chaining @see me.Sprite#animationspeed
[ "reverse", "the", "given", "or", "current", "animation", "if", "none", "is", "specified" ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/dist/melonjs.js#L10958-L10966
train
melonjs/melonJS
dist/melonjs.js
setRegion
function setRegion(region) { if (this.source !== null) { // set the source texture for the given region this.image = this.source.getTexture(region); } // set the sprite offset within the texture this.current.offset.setV(region.offset); // set angle if defined ...
javascript
function setRegion(region) { if (this.source !== null) { // set the source texture for the given region this.image = this.source.getTexture(region); } // set the sprite offset within the texture this.current.offset.setV(region.offset); // set angle if defined ...
[ "function", "setRegion", "(", "region", ")", "{", "if", "(", "this", ".", "source", "!==", "null", ")", "{", "// set the source texture for the given region", "this", ".", "image", "=", "this", ".", "source", ".", "getTexture", "(", "region", ")", ";", "}", ...
change the current texture atlas region for this sprite @see me.Texture.getRegion @name setRegion @memberOf me.Sprite.prototype @function @param {Object} region typically returned through me.Texture.getRegion() @return {me.Sprite} Reference to this object for method chaining @example // change the sprite to "shadedDark...
[ "change", "the", "current", "texture", "atlas", "region", "for", "this", "sprite" ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/dist/melonjs.js#L10996-L11015
train
melonjs/melonJS
dist/melonjs.js
setAnimationFrame
function setAnimationFrame(idx) { this.current.idx = (idx || 0) % this.current.length; return this.setRegion(this.getAnimationFrameObjectByIndex(this.current.idx)); }
javascript
function setAnimationFrame(idx) { this.current.idx = (idx || 0) % this.current.length; return this.setRegion(this.getAnimationFrameObjectByIndex(this.current.idx)); }
[ "function", "setAnimationFrame", "(", "idx", ")", "{", "this", ".", "current", ".", "idx", "=", "(", "idx", "||", "0", ")", "%", "this", ".", "current", ".", "length", ";", "return", "this", ".", "setRegion", "(", "this", ".", "getAnimationFrameObjectByI...
force the current animation frame index. @name setAnimationFrame @memberOf me.Sprite.prototype @function @param {Number} [index=0] animation frame index @return {me.Sprite} Reference to this object for method chaining @example // reset the current animation to the first frame this.setAnimationFrame();
[ "force", "the", "current", "animation", "frame", "index", "." ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/dist/melonjs.js#L11028-L11031
train
melonjs/melonJS
dist/melonjs.js
onAnchorUpdate
function onAnchorUpdate(newX, newY) { // since the callback is called before setting the new value // manually update the anchor point (required for updateBoundsPos) this.anchorPoint.setMuted(newX, newY); // then call updateBouds this.updateBoundsPos(this.pos.x, this.pos.y); ...
javascript
function onAnchorUpdate(newX, newY) { // since the callback is called before setting the new value // manually update the anchor point (required for updateBoundsPos) this.anchorPoint.setMuted(newX, newY); // then call updateBouds this.updateBoundsPos(this.pos.x, this.pos.y); ...
[ "function", "onAnchorUpdate", "(", "newX", ",", "newY", ")", "{", "// since the callback is called before setting the new value", "// manually update the anchor point (required for updateBoundsPos)", "this", ".", "anchorPoint", ".", "setMuted", "(", "newX", ",", "newY", ")", ...
called when the anchor point value is changed @private @name onAnchorUpdate @memberOf me.Sprite.prototype @function
[ "called", "when", "the", "anchor", "point", "value", "is", "changed" ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/dist/melonjs.js#L11131-L11137
train
melonjs/melonJS
dist/melonjs.js
update
function update(dt) { // call the parent constructor var updated = this._super(me.Sprite, "update", [dt]); // check if the button was updated if (this.updated) { // clear the flag if (!this.released) { this.updated = false; } return ...
javascript
function update(dt) { // call the parent constructor var updated = this._super(me.Sprite, "update", [dt]); // check if the button was updated if (this.updated) { // clear the flag if (!this.released) { this.updated = false; } return ...
[ "function", "update", "(", "dt", ")", "{", "// call the parent constructor", "var", "updated", "=", "this", ".", "_super", "(", "me", ".", "Sprite", ",", "\"update\"", ",", "[", "dt", "]", ")", ";", "// check if the button was updated", "if", "(", "this", "....
return true if the object has been clicked @ignore
[ "return", "true", "if", "the", "object", "has", "been", "clicked" ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/dist/melonjs.js#L11292-L11308
train
melonjs/melonJS
dist/melonjs.js
leave
function leave(event) { this.hover = false; this.release.call(this, event); return this.onOut.call(this, event); }
javascript
function leave(event) { this.hover = false; this.release.call(this, event); return this.onOut.call(this, event); }
[ "function", "leave", "(", "event", ")", "{", "this", ".", "hover", "=", "false", ";", "this", ".", "release", ".", "call", "(", "this", ",", "event", ")", ";", "return", "this", ".", "onOut", ".", "call", "(", "this", ",", "event", ")", ";", "}" ...
function callback for the pointerLeave event @ignore
[ "function", "callback", "for", "the", "pointerLeave", "event" ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/dist/melonjs.js#L11374-L11378
train
melonjs/melonJS
dist/melonjs.js
onActivateEvent
function onActivateEvent() { // register pointer events me.input.registerPointerEvent("pointerdown", this, this.clicked.bind(this)); me.input.registerPointerEvent("pointerup", this, this.release.bind(this)); me.input.registerPointerEvent("pointercancel", this, this.release.bind(this)...
javascript
function onActivateEvent() { // register pointer events me.input.registerPointerEvent("pointerdown", this, this.clicked.bind(this)); me.input.registerPointerEvent("pointerup", this, this.release.bind(this)); me.input.registerPointerEvent("pointercancel", this, this.release.bind(this)...
[ "function", "onActivateEvent", "(", ")", "{", "// register pointer events", "me", ".", "input", ".", "registerPointerEvent", "(", "\"pointerdown\"", ",", "this", ",", "this", ".", "clicked", ".", "bind", "(", "this", ")", ")", ";", "me", ".", "input", ".", ...
function called when added to the game world or a container @ignore
[ "function", "called", "when", "added", "to", "the", "game", "world", "or", "a", "container" ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/dist/melonjs.js#L11444-L11451
train
melonjs/melonJS
dist/melonjs.js
onDeactivateEvent
function onDeactivateEvent() { // release pointer events me.input.releasePointerEvent("pointerdown", this); me.input.releasePointerEvent("pointerup", this); me.input.releasePointerEvent("pointercancel", this); me.input.releasePointerEvent("pointerenter", this); me.i...
javascript
function onDeactivateEvent() { // release pointer events me.input.releasePointerEvent("pointerdown", this); me.input.releasePointerEvent("pointerup", this); me.input.releasePointerEvent("pointercancel", this); me.input.releasePointerEvent("pointerenter", this); me.i...
[ "function", "onDeactivateEvent", "(", ")", "{", "// release pointer events", "me", ".", "input", ".", "releasePointerEvent", "(", "\"pointerdown\"", ",", "this", ")", ";", "me", ".", "input", ".", "releasePointerEvent", "(", "\"pointerup\"", ",", "this", ")", ";...
function called when removed from the game world or a container @ignore
[ "function", "called", "when", "removed", "from", "the", "game", "world", "or", "a", "container" ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/dist/melonjs.js#L11457-L11465
train
melonjs/melonJS
dist/melonjs.js
getChildAt
function getChildAt(index) { if (index >= 0 && index < this.children.length) { return this.children[index]; } else { throw new Error("Index (" + index + ") Out Of Bounds for getChildAt()"); } }
javascript
function getChildAt(index) { if (index >= 0 && index < this.children.length) { return this.children[index]; } else { throw new Error("Index (" + index + ") Out Of Bounds for getChildAt()"); } }
[ "function", "getChildAt", "(", "index", ")", "{", "if", "(", "index", ">=", "0", "&&", "index", "<", "this", ".", "children", ".", "length", ")", "{", "return", "this", ".", "children", "[", "index", "]", ";", "}", "else", "{", "throw", "new", "Err...
Returns the Child at the specified index @name getChildAt @memberOf me.Container.prototype @function @param {Number} index
[ "Returns", "the", "Child", "at", "the", "specified", "index" ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/dist/melonjs.js#L11782-L11788
train
melonjs/melonJS
dist/melonjs.js
getNextChild
function getNextChild(child) { var index = this.children.indexOf(child) - 1; if (index >= 0 && index < this.children.length) { return this.getChildAt(index); } return undefined; }
javascript
function getNextChild(child) { var index = this.children.indexOf(child) - 1; if (index >= 0 && index < this.children.length) { return this.getChildAt(index); } return undefined; }
[ "function", "getNextChild", "(", "child", ")", "{", "var", "index", "=", "this", ".", "children", ".", "indexOf", "(", "child", ")", "-", "1", ";", "if", "(", "index", ">=", "0", "&&", "index", "<", "this", ".", "children", ".", "length", ")", "{",...
Returns the next child within the container or undefined if none @name getNextChild @memberOf me.Container @function @param {me.Renderable} child
[ "Returns", "the", "next", "child", "within", "the", "container", "or", "undefined", "if", "none" ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/dist/melonjs.js#L11808-L11816
train
melonjs/melonJS
dist/melonjs.js
getChildByType
function getChildByType(_class) { var objList = []; for (var i = this.children.length - 1; i >= 0; i--) { var obj = this.children[i]; if (obj instanceof _class) { objList.push(obj); } if (obj instanceof me.Container) { objList = ...
javascript
function getChildByType(_class) { var objList = []; for (var i = this.children.length - 1; i >= 0; i--) { var obj = this.children[i]; if (obj instanceof _class) { objList.push(obj); } if (obj instanceof me.Container) { objList = ...
[ "function", "getChildByType", "(", "_class", ")", "{", "var", "objList", "=", "[", "]", ";", "for", "(", "var", "i", "=", "this", ".", "children", ".", "length", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "var", "obj", "=", "this"...
returns the list of childs with the specified class type @name getChildByType @memberOf me.Container.prototype @public @function @param {Object} class type @return {me.Renderable[]} Array of children
[ "returns", "the", "list", "of", "childs", "with", "the", "specified", "class", "type" ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/dist/melonjs.js#L11892-L11908
train
melonjs/melonJS
dist/melonjs.js
updateChildBounds
function updateChildBounds() { this.childBounds.pos.set(Infinity, Infinity); this.childBounds.resize(-Infinity, -Infinity); var childBounds; for (var i = this.children.length, child; i--, child = this.children[i];) { if (child.isRenderable) { if (child instan...
javascript
function updateChildBounds() { this.childBounds.pos.set(Infinity, Infinity); this.childBounds.resize(-Infinity, -Infinity); var childBounds; for (var i = this.children.length, child; i--, child = this.children[i];) { if (child.isRenderable) { if (child instan...
[ "function", "updateChildBounds", "(", ")", "{", "this", ".", "childBounds", ".", "pos", ".", "set", "(", "Infinity", ",", "Infinity", ")", ";", "this", ".", "childBounds", ".", "resize", "(", "-", "Infinity", ",", "-", "Infinity", ")", ";", "var", "chi...
resizes the child bounds rectangle, based on children bounds. @name updateChildBounds @memberOf me.Container.prototype @function @return {me.Rect} updated child bounds
[ "resizes", "the", "child", "bounds", "rectangle", "based", "on", "children", "bounds", "." ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/dist/melonjs.js#L11949-L11971
train
melonjs/melonJS
dist/melonjs.js
isAttachedToRoot
function isAttachedToRoot() { if (this.root === true) { return true; } else { var ancestor = this.ancestor; while (ancestor) { if (ancestor.root === true) { return true; } ancestor = ancestor.ancestor; ...
javascript
function isAttachedToRoot() { if (this.root === true) { return true; } else { var ancestor = this.ancestor; while (ancestor) { if (ancestor.root === true) { return true; } ancestor = ancestor.ancestor; ...
[ "function", "isAttachedToRoot", "(", ")", "{", "if", "(", "this", ".", "root", "===", "true", ")", "{", "return", "true", ";", "}", "else", "{", "var", "ancestor", "=", "this", ".", "ancestor", ";", "while", "(", "ancestor", ")", "{", "if", "(", "a...
Checks if this container is root or if it's attached to the root container. @private @name isAttachedToRoot @memberOf me.Container.prototype @function @returns Boolean
[ "Checks", "if", "this", "container", "is", "root", "or", "if", "it", "s", "attached", "to", "the", "root", "container", "." ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/dist/melonjs.js#L11981-L11997
train
melonjs/melonJS
dist/melonjs.js
removeChild
function removeChild(child, keepalive) { if (this.hasChild(child)) { me.utils.function.defer(deferredRemove, this, child, keepalive); } else { throw new Error("Child is not mine."); } }
javascript
function removeChild(child, keepalive) { if (this.hasChild(child)) { me.utils.function.defer(deferredRemove, this, child, keepalive); } else { throw new Error("Child is not mine."); } }
[ "function", "removeChild", "(", "child", ",", "keepalive", ")", "{", "if", "(", "this", ".", "hasChild", "(", "child", ")", ")", "{", "me", ".", "utils", ".", "function", ".", "defer", "(", "deferredRemove", ",", "this", ",", "child", ",", "keepalive",...
Invokes the removeChildNow in a defer, to ensure the child is removed safely after the update & draw stack has completed @name removeChild @memberOf me.Container.prototype @public @function @param {me.Renderable} child @param {Boolean} [keepalive=False] True to prevent calling child.destroy()
[ "Invokes", "the", "removeChildNow", "in", "a", "defer", "to", "ensure", "the", "child", "is", "removed", "safely", "after", "the", "update", "&", "draw", "stack", "has", "completed" ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/dist/melonjs.js#L12046-L12052
train
melonjs/melonJS
dist/melonjs.js
setChildsProperty
function setChildsProperty(prop, val, recursive) { for (var i = this.children.length; i >= 0; i--) { var obj = this.children[i]; if (recursive === true && obj instanceof me.Container) { obj.setChildsProperty(prop, val, recursive); } obj[prop] = val; ...
javascript
function setChildsProperty(prop, val, recursive) { for (var i = this.children.length; i >= 0; i--) { var obj = this.children[i]; if (recursive === true && obj instanceof me.Container) { obj.setChildsProperty(prop, val, recursive); } obj[prop] = val; ...
[ "function", "setChildsProperty", "(", "prop", ",", "val", ",", "recursive", ")", "{", "for", "(", "var", "i", "=", "this", ".", "children", ".", "length", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "var", "obj", "=", "this", ".", "children", ...
Automatically set the specified property of all childs to the given value @name setChildsProperty @memberOf me.Container.prototype @function @param {String} property property name @param {Object} value property value @param {Boolean} [recursive=false] recursively apply the value to child containers if true
[ "Automatically", "set", "the", "specified", "property", "of", "all", "childs", "to", "the", "given", "value" ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/dist/melonjs.js#L12100-L12110
train
melonjs/melonJS
dist/melonjs.js
_sortZ
function _sortZ(a, b) { return b.pos && a.pos ? b.pos.z - a.pos.z : a.pos ? -Infinity : Infinity; }
javascript
function _sortZ(a, b) { return b.pos && a.pos ? b.pos.z - a.pos.z : a.pos ? -Infinity : Infinity; }
[ "function", "_sortZ", "(", "a", ",", "b", ")", "{", "return", "b", ".", "pos", "&&", "a", ".", "pos", "?", "b", ".", "pos", ".", "z", "-", "a", ".", "pos", ".", "z", ":", "a", ".", "pos", "?", "-", "Infinity", ":", "Infinity", ";", "}" ]
Z Sorting function @ignore
[ "Z", "Sorting", "function" ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/dist/melonjs.js#L12230-L12232
train
melonjs/melonJS
dist/melonjs.js
setDeadzone
function setDeadzone(w, h) { if (typeof this.deadzone === "undefined") { this.deadzone = new me.Rect(0, 0, 0, 0); } // reusing the old code for now... this.deadzone.pos.set(~~((this.width - w) / 2), ~~((this.height - h) / 2 - h * 0.25)); this.deadzone.resize(w, h); ...
javascript
function setDeadzone(w, h) { if (typeof this.deadzone === "undefined") { this.deadzone = new me.Rect(0, 0, 0, 0); } // reusing the old code for now... this.deadzone.pos.set(~~((this.width - w) / 2), ~~((this.height - h) / 2 - h * 0.25)); this.deadzone.resize(w, h); ...
[ "function", "setDeadzone", "(", "w", ",", "h", ")", "{", "if", "(", "typeof", "this", ".", "deadzone", "===", "\"undefined\"", ")", "{", "this", ".", "deadzone", "=", "new", "me", ".", "Rect", "(", "0", ",", "0", ",", "0", ",", "0", ")", ";", "...
change the deadzone settings. the "deadzone" defines an area within the current camera in which the followed renderable can move without scrolling the camera. @name setDeadzone @see me.Camera2d.follow @memberOf me.Camera2d @function @param {Number} w deadzone width @param {Number} h deadzone height
[ "change", "the", "deadzone", "settings", ".", "the", "deadzone", "defines", "an", "area", "within", "the", "current", "camera", "in", "which", "the", "followed", "renderable", "can", "move", "without", "scrolling", "the", "camera", "." ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/dist/melonjs.js#L12548-L12560
train
melonjs/melonJS
dist/melonjs.js
resize
function resize(w, h) { // parent consctructor, resize camera rect this._super(me.Renderable, "resize", [w, h]); // disable damping while resizing this.smoothFollow = false; // update bounds var level = me.levelDirector.getCurrentLevel(); this.setBounds(0, 0, Math.max(w, ...
javascript
function resize(w, h) { // parent consctructor, resize camera rect this._super(me.Renderable, "resize", [w, h]); // disable damping while resizing this.smoothFollow = false; // update bounds var level = me.levelDirector.getCurrentLevel(); this.setBounds(0, 0, Math.max(w, ...
[ "function", "resize", "(", "w", ",", "h", ")", "{", "// parent consctructor, resize camera rect", "this", ".", "_super", "(", "me", ".", "Renderable", ",", "\"resize\"", ",", "[", "w", ",", "h", "]", ")", ";", "// disable damping while resizing", "this", ".", ...
resize the camera @name resize @memberOf me.Camera2d @function @param {Number} w new width of the camera @param {Number} h new height of the camera @return {me.Camera2d} this camera
[ "resize", "the", "camera" ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/dist/melonjs.js#L12571-L12586
train
melonjs/melonJS
dist/melonjs.js
move
function move(x, y) { this.moveTo(this.pos.x + x, this.pos.y + y); }
javascript
function move(x, y) { this.moveTo(this.pos.x + x, this.pos.y + y); }
[ "function", "move", "(", "x", ",", "y", ")", "{", "this", ".", "moveTo", "(", "this", ".", "pos", ".", "x", "+", "x", ",", "this", ".", "pos", ".", "y", "+", "y", ")", ";", "}" ]
move the camera upper-left position by the specified offset. @name move @memberOf me.Camera2d @see me.Camera2d.focusOn @function @param {Number} x @param {Number} y @example // Move the camera up by four pixels me.game.viewport.move(0, -4);
[ "move", "the", "camera", "upper", "-", "left", "position", "by", "the", "specified", "offset", "." ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/dist/melonjs.js#L12668-L12670
train
melonjs/melonJS
dist/melonjs.js
shake
function shake(intensity, duration, axis, onComplete, force) { if (this._shake.duration === 0 || force === true) { this._shake.intensity = intensity; this._shake.duration = duration; this._shake.axis = axis || this.AXIS.BOTH; this._shake.onComplete = typeof onComplet...
javascript
function shake(intensity, duration, axis, onComplete, force) { if (this._shake.duration === 0 || force === true) { this._shake.intensity = intensity; this._shake.duration = duration; this._shake.axis = axis || this.AXIS.BOTH; this._shake.onComplete = typeof onComplet...
[ "function", "shake", "(", "intensity", ",", "duration", ",", "axis", ",", "onComplete", ",", "force", ")", "{", "if", "(", "this", ".", "_shake", ".", "duration", "===", "0", "||", "force", "===", "true", ")", "{", "this", ".", "_shake", ".", "intens...
shake the camera @name shake @memberOf me.Camera2d @function @param {Number} intensity maximum offset that the screen can be moved while shaking @param {Number} duration expressed in milliseconds @param {me.Camera2d.AXIS} [axis=this.AXIS.BOTH] specify on which axis you want the shake effect @param {Function} [onComplet...
[ "shake", "the", "camera" ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/dist/melonjs.js#L12797-L12804
train
melonjs/melonJS
dist/melonjs.js
drawFX
function drawFX(renderer) { // fading effect if (this._fadeIn.tween) { renderer.clearColor(this._fadeIn.color); // remove the tween if over if (this._fadeIn.color.alpha === 1.0) { this._fadeIn.tween = null; me.pool.push(this._fadeIn.color); ...
javascript
function drawFX(renderer) { // fading effect if (this._fadeIn.tween) { renderer.clearColor(this._fadeIn.color); // remove the tween if over if (this._fadeIn.color.alpha === 1.0) { this._fadeIn.tween = null; me.pool.push(this._fadeIn.color); ...
[ "function", "drawFX", "(", "renderer", ")", "{", "// fading effect", "if", "(", "this", ".", "_fadeIn", ".", "tween", ")", "{", "renderer", ".", "clearColor", "(", "this", ".", "_fadeIn", ".", "color", ")", ";", "// remove the tween if over", "if", "(", "t...
render the camera effects @ignore
[ "render", "the", "camera", "effects" ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/dist/melonjs.js#L12961-L12983
train
melonjs/melonJS
dist/melonjs.js
draw
function draw(renderer, container) { var translateX = this.pos.x + this.offset.x; var translateY = this.pos.y + this.offset.y; // translate the world coordinates by default to screen coordinates container.currentTransform.translate(-translateX, -translateY); // clip to camera bounds ...
javascript
function draw(renderer, container) { var translateX = this.pos.x + this.offset.x; var translateY = this.pos.y + this.offset.y; // translate the world coordinates by default to screen coordinates container.currentTransform.translate(-translateX, -translateY); // clip to camera bounds ...
[ "function", "draw", "(", "renderer", ",", "container", ")", "{", "var", "translateX", "=", "this", ".", "pos", ".", "x", "+", "this", ".", "offset", ".", "x", ";", "var", "translateY", "=", "this", ".", "pos", ".", "y", "+", "this", ".", "offset", ...
draw all object visibile in this viewport @ignore
[ "draw", "all", "object", "visibile", "in", "this", "viewport" ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/dist/melonjs.js#L12989-L13007
train
melonjs/melonJS
dist/melonjs.js
distanceTo
function distanceTo(e) { var a = this.getBounds(); var b = e.getBounds(); // the me.Vector2d object also implements the same function, but // we have to use here the center of both entities var dx = a.pos.x + a.width / 2 - (b.pos.x + b.width / 2); var dy = a.pos.y + a.heigh...
javascript
function distanceTo(e) { var a = this.getBounds(); var b = e.getBounds(); // the me.Vector2d object also implements the same function, but // we have to use here the center of both entities var dx = a.pos.x + a.width / 2 - (b.pos.x + b.width / 2); var dy = a.pos.y + a.heigh...
[ "function", "distanceTo", "(", "e", ")", "{", "var", "a", "=", "this", ".", "getBounds", "(", ")", ";", "var", "b", "=", "e", ".", "getBounds", "(", ")", ";", "// the me.Vector2d object also implements the same function, but", "// we have to use here the center of b...
return the distance to the specified entity @name distanceTo @memberOf me.Entity @function @param {me.Entity} entity Entity @return {Number} distance
[ "return", "the", "distance", "to", "the", "specified", "entity" ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/dist/melonjs.js#L13146-L13154
train
melonjs/melonJS
dist/melonjs.js
distanceToPoint
function distanceToPoint(v) { var a = this.getBounds(); // the me.Vector2d object also implements the same function, but // we have to use here the center of both entities var dx = a.pos.x + a.width / 2 - v.x; var dy = a.pos.y + a.height / 2 - v.y; return Math.sqrt(dx * dx ...
javascript
function distanceToPoint(v) { var a = this.getBounds(); // the me.Vector2d object also implements the same function, but // we have to use here the center of both entities var dx = a.pos.x + a.width / 2 - v.x; var dy = a.pos.y + a.height / 2 - v.y; return Math.sqrt(dx * dx ...
[ "function", "distanceToPoint", "(", "v", ")", "{", "var", "a", "=", "this", ".", "getBounds", "(", ")", ";", "// the me.Vector2d object also implements the same function, but", "// we have to use here the center of both entities", "var", "dx", "=", "a", ".", "pos", ".",...
return the distance to the specified point @name distanceToPoint @memberOf me.Entity @function @param {me.Vector2d} vector vector @return {Number} distance
[ "return", "the", "distance", "to", "the", "specified", "point" ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/dist/melonjs.js#L13164-L13171
train
melonjs/melonJS
dist/melonjs.js
angleTo
function angleTo(e) { var a = this.getBounds(); var b = e.getBounds(); // the me.Vector2d object also implements the same function, but // we have to use here the center of both entities var ax = b.pos.x + b.width / 2 - (a.pos.x + a.width / 2); var ay = b.pos.y + b.height /...
javascript
function angleTo(e) { var a = this.getBounds(); var b = e.getBounds(); // the me.Vector2d object also implements the same function, but // we have to use here the center of both entities var ax = b.pos.x + b.width / 2 - (a.pos.x + a.width / 2); var ay = b.pos.y + b.height /...
[ "function", "angleTo", "(", "e", ")", "{", "var", "a", "=", "this", ".", "getBounds", "(", ")", ";", "var", "b", "=", "e", ".", "getBounds", "(", ")", ";", "// the me.Vector2d object also implements the same function, but", "// we have to use here the center of both...
return the angle to the specified entity @name angleTo @memberOf me.Entity @function @param {me.Entity} entity Entity @return {Number} angle in radians
[ "return", "the", "angle", "to", "the", "specified", "entity" ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/dist/melonjs.js#L13181-L13189
train
melonjs/melonJS
dist/melonjs.js
angleToPoint
function angleToPoint(v) { var a = this.getBounds(); // the me.Vector2d object also implements the same function, but // we have to use here the center of both entities var ax = v.x - (a.pos.x + a.width / 2); var ay = v.y - (a.pos.y + a.height / 2); return Math.atan2(ay, ax...
javascript
function angleToPoint(v) { var a = this.getBounds(); // the me.Vector2d object also implements the same function, but // we have to use here the center of both entities var ax = v.x - (a.pos.x + a.width / 2); var ay = v.y - (a.pos.y + a.height / 2); return Math.atan2(ay, ax...
[ "function", "angleToPoint", "(", "v", ")", "{", "var", "a", "=", "this", ".", "getBounds", "(", ")", ";", "// the me.Vector2d object also implements the same function, but", "// we have to use here the center of both entities", "var", "ax", "=", "v", ".", "x", "-", "(...
return the angle to the specified point @name angleToPoint @memberOf me.Entity @function @param {me.Vector2d} vector vector @return {Number} angle in radians
[ "return", "the", "angle", "to", "the", "specified", "point" ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/dist/melonjs.js#L13199-L13206
train
melonjs/melonJS
dist/melonjs.js
updateBoundsPos
function updateBoundsPos(x, y) { if (typeof this.body !== "undefined") { var _pos = this.body.pos; this._super(me.Renderable, "updateBoundsPos", [x + _pos.x, y + _pos.y]); } else { this._super(me.Renderable, "updateBoundsPos", [x, y]); } return this...
javascript
function updateBoundsPos(x, y) { if (typeof this.body !== "undefined") { var _pos = this.body.pos; this._super(me.Renderable, "updateBoundsPos", [x + _pos.x, y + _pos.y]); } else { this._super(me.Renderable, "updateBoundsPos", [x, y]); } return this...
[ "function", "updateBoundsPos", "(", "x", ",", "y", ")", "{", "if", "(", "typeof", "this", ".", "body", "!==", "\"undefined\"", ")", "{", "var", "_pos", "=", "this", ".", "body", ".", "pos", ";", "this", ".", "_super", "(", "me", ".", "Renderable", ...
update the bounds position when the position is modified @private @name updateBoundsPos @memberOf me.Entity @function
[ "update", "the", "bounds", "position", "when", "the", "position", "is", "modified" ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/dist/melonjs.js#L13224-L13234
train
melonjs/melonJS
dist/melonjs.js
preloadTMX
function preloadTMX(tmxData, onload, onerror) { function addToTMXList(data) { // set the TMX content tmxList[tmxData.name] = data; // add the tmx to the levelDirector if (tmxData.type === "tmx") { me.levelDirector.addTMXLevel(tmxData.name); } }...
javascript
function preloadTMX(tmxData, onload, onerror) { function addToTMXList(data) { // set the TMX content tmxList[tmxData.name] = data; // add the tmx to the levelDirector if (tmxData.type === "tmx") { me.levelDirector.addTMXLevel(tmxData.name); } }...
[ "function", "preloadTMX", "(", "tmxData", ",", "onload", ",", "onerror", ")", "{", "function", "addToTMXList", "(", "data", ")", "{", "// set the TMX content", "tmxList", "[", "tmxData", ".", "name", "]", "=", "data", ";", "// add the tmx to the levelDirector", ...
preload TMX files @ignore
[ "preload", "TMX", "files" ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/dist/melonjs.js#L14360-L14452
train
melonjs/melonJS
dist/melonjs.js
setFont
function setFont(font, size) { // font name and type var font_names = font.split(",").map(function (value) { value = value.trim(); return !/(^".*"$)|(^'.*'$)/.test(value) ? "\"" + value + "\"" : value; }); // font size if (typeof size === "number") { ...
javascript
function setFont(font, size) { // font name and type var font_names = font.split(",").map(function (value) { value = value.trim(); return !/(^".*"$)|(^'.*'$)/.test(value) ? "\"" + value + "\"" : value; }); // font size if (typeof size === "number") { ...
[ "function", "setFont", "(", "font", ",", "size", ")", "{", "// font name and type", "var", "font_names", "=", "font", ".", "split", "(", "\",\"", ")", ".", "map", "(", "function", "(", "value", ")", "{", "value", "=", "value", ".", "trim", "(", ")", ...
set the font family and size @name setFont @memberOf me.Text.prototype @function @param {String} font a CSS font name @param {Number|String} size size, or size + suffix (px, em, pt) @return this object for chaining @example font.setFont("Arial", 20); font.setFont("Arial", "1.5em");
[ "set", "the", "font", "family", "and", "size" ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/dist/melonjs.js#L15253-L15282
train
melonjs/melonJS
dist/melonjs.js
setText
function setText(value) { value = "" + value; if (this._text !== value) { if (Array.isArray(value)) { this._text = value.join("\n"); } else { this._text = value; } this.isDirty = true; } return this; }
javascript
function setText(value) { value = "" + value; if (this._text !== value) { if (Array.isArray(value)) { this._text = value.join("\n"); } else { this._text = value; } this.isDirty = true; } return this; }
[ "function", "setText", "(", "value", ")", "{", "value", "=", "\"\"", "+", "value", ";", "if", "(", "this", ".", "_text", "!==", "value", ")", "{", "if", "(", "Array", ".", "isArray", "(", "value", ")", ")", "{", "this", ".", "_text", "=", "value"...
change the text to be displayed @name setText @memberOf me.Text.prototype @function @param {Number|String|String[]} value a string, or an array of strings @return this object for chaining
[ "change", "the", "text", "to", "be", "displayed" ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/dist/melonjs.js#L15292-L15306
train
melonjs/melonJS
dist/melonjs.js
measureTextWidth
function measureTextWidth(font, text) { var characters = text.split(""); var width = 0; var lastGlyph = null; for (var i = 0; i < characters.length; i++) { var ch = characters[i].charCodeAt(0); var glyph = font.fontData.glyphs[ch]; var kerning = lastGlyph && lastG...
javascript
function measureTextWidth(font, text) { var characters = text.split(""); var width = 0; var lastGlyph = null; for (var i = 0; i < characters.length; i++) { var ch = characters[i].charCodeAt(0); var glyph = font.fontData.glyphs[ch]; var kerning = lastGlyph && lastG...
[ "function", "measureTextWidth", "(", "font", ",", "text", ")", "{", "var", "characters", "=", "text", ".", "split", "(", "\"\"", ")", ";", "var", "width", "=", "0", ";", "var", "lastGlyph", "=", "null", ";", "for", "(", "var", "i", "=", "0", ";", ...
Measures the width of a single line of text, does not account for \n @ignore
[ "Measures", "the", "width", "of", "a", "single", "line", "of", "text", "does", "not", "account", "for", "\\", "n" ]
6c1823cc245df7c958db243a0531506eb838d72c
https://github.com/melonjs/melonJS/blob/6c1823cc245df7c958db243a0531506eb838d72c/dist/melonjs.js#L15476-L15490
train