new World()
- Source:
- core/world.js, line 23
Members
-
$c
-
Define component.
if component already defined under @name function return component with config customization.
if component doesn't define function defines it the world under @name with @config state.
But if config doesn't defined it's rise exception- Source:
- core/world.js, line 363
-
$e :Function
-
Build and add Entity
- Source:
- core/world.js, line 275
- See:
Example
//config as array GameEngine.e('player', [ 'ngDOM', { color: 'rgb(255,0,0)' }, 'ng2D', { x: 0, y: 50 }, 'ngControl', 'ngCollision' ])); //or config as object GameEngine.e('player', { ngDOM: { color: 'rgb(255,0,0)' }, ng2D: {x : 0, y: 50}, ngControl: {}, ngCollision: {} }));
-
$s
-
Build instance of System. Instantiate injected system or define custom system.
- Source:
- core/world.js, line 482
- See:
Example
world.$s('healerSystem', { //apply to components: $require: ['ngLife', 'healer'], //iterate each frame for each entity $update: ['$node', function($node) { if ($node.ngLife.life <= this.healer.maxLife) { //heals entity $node.ngLife.life += this.healer.power; } else { //stop healing when life reach of maxLife $node.$remove('healer'); } }] });
Methods
-
<private> $$addEntity(instance) → {Entity}
-
Add Entity to the World
Parameters:
Name Type Description instance
Entity The instance of Entity
- Source:
- core/world.js, line 96
Returns:
- Type
- Entity
-
<private> $$addSystem(instance) → {System}
-
Add system by instance
Parameters:
Name Type Description instance
System - Source:
- core/world.js, line 188
Returns:
- Type
- System
-
<private> $$getSystemByName(name) → {System}
-
Get add System by name
Parameters:
Name Type Description name
string - Source:
- core/world.js, line 158
Returns:
- Type
- System
-
<private> $$removeEntity(instance) → {Entity}
-
Remove Entity from the World
Parameters:
Name Type Description instance
Entity - Source:
- core/world.js, line 110
Returns:
- Type
- Entity
-
<private> $$removeSystem(instance) → {System}
-
Remove System by instance
Parameters:
Name Type Description instance
System - Source:
- core/world.js, line 206
Returns:
- Type
- System
-
$add(value, config) → {Entity|System}
-
Add Entity or System to the World
Parameters:
Name Type Argument Description value
Entity | System | String The Entity or the System
config
Object <optional>
The config of the added instance
- Source:
- core/world.js, line 76
Returns:
-
$getByName(value) → {Entity}
-
Get entity by name
Parameters:
Name Type Description value
string - Source:
- core/world.js, line 222
Returns:
- Type
- Entity
-
$has(name) → {boolean}
-
Is contain definition of Component, Module or System
Parameters:
Name Type Description name
string The name of Component, Module or System
- Source:
- core/world.js, line 49
Returns:
- Type
- boolean
-
$isUse(value) → {boolean}
-
Is System used (added) in the World
Parameters:
Name Type Description value
string | System The name or instance of System
- Source:
- core/world.js, line 60
Returns:
- Type
- boolean
-
$numEntities() → {number}
-
Get number of entities
- Source:
- core/world.js, line 239
Returns:
- Type
- number
-
$queryByComponents(request) → {*}
-
Query nodes by them components.
Parameters:
Name Type Description request
array | string The request filter
- Source:
- core/world.js, line 744
- See:
Returns:
- Type
- *
-
$remove(instance)
-
Remove Entity or System for the World
Parameters:
Name Type Description instance
Entity | System - Source:
- core/world.js, line 172
-
$start()
-
Start update the World every 1/60 of second
- Source:
- core/world.js, line 807
-
$stop()
-
Stop update the World every 1/60 of second
- Source:
- core/world.js, line 833
-
$update(time)
-
Update the World by interval
Parameters:
Name Type Description time
number The time interval
- Source:
- core/world.js, line 781