API / Core / Re
Usage
//query for all entities with the image comp
re('image');
//logs current EntityJS version
console.log(re.version);
//start loading upon ready
re.ready(function(){
re.sys.start('#game-canvas').start();
});
//new entity
re.entity('image');
//or
re.e('image');
//new comp
re.comp('bit');
//or
re.c('bit');
Description
Re is the EntityJS namespaces it contains static methods and a function for querying. For query usage checkout Query comp.
Statics
-
.$(selector)
Selects DOM elements. Right now only selects by id or by tags.
re.$('#myCanvas'). -
.c(name)
A shortcut method to the
.comp. (Yeah I know its like soooo much work) -
.comp(name)
Returns a component with the given name. If it does not exist it will automatically be created.
-
.e(comps, count)
A shortcut method to the
.entity. -
.entity(comps, count)
Creates and returns an entity with the given components. Optionally the second argument will create the specified amount of entities and return a query. Example
re.entity('image m.png', 10). -
.ready(function)
Will call the given function when the page is finished loading.
-
.version
Current version of EntityJS.
Init
-
.(query)
Creates and returns a new query with the results. Look at the Query component for in depth usage.
Defines
-
.$new(element)
Creates a new HTML element. Usually used to create an extra canvas.
-
.(query)
Creates and returns a new query with the results. Look at the Query component for in depth usage.
-
.is(object, type = 'any')
Checks if a variable is defined or is of given type. Use this instead of typeof.
var obj = {};
re.is(obj.ok); //false not defined
obj.ok = 'value';
re.is(obj.ok); //true is defined
re.is(obj.ok, 'string'); //true is of type string
re.is(obj.ok, 'String'); //true
Updated / added in version 0.3.0
Last Updated Mar 01, 2012