Skip to content

Commit

Permalink
README.md elaborations on entityAdded and entityRemoved
Browse files Browse the repository at this point in the history
  • Loading branch information
alexdmiller committed Jun 15, 2014
1 parent 327b3f1 commit 373717b
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ requestAnimationFrame(function () {
})
```

A system is notified when it is added or removed from a World:
A system is notified when it is added or removed from the world:

```
```js
var MySystem = CES.System.extend({
addedToWorld: function(world) {
// Code to handle being added to world. Remeber to call this._super.
Expand All @@ -105,15 +105,23 @@ var MySystem = CES.System.extend({
});
```

A World emits signals when entities are added or removed. You can listen for
The world emits signals when entities are added or removed. You can listen for
specific entities and handle the signal accordingly:

```
```js
var MySystem = CES.System.extend({
addedToWorld: function(world) {
world.entityAdded('position', 'velocity').add(function(entity) {
// This function is called whenever an entity with both 'position' and
// 'velocity' components is added to the World.
// 'velocity' components is added to the world. It can also be called when
// a component is added to an entity; for example, when an entity with
// only 'position' has 'velocity' added to it.
});
world.entityRemoved('position', 'velocity').add(function(entity) {
// This function is called whenever an entity with both 'position' and
// 'velocity' components is removed from the world. It can also be called
// when a component is removed from an entity; for example, when an entity
// with both 'position' and 'velocity' has 'velocity' removed from it.
});
}
});
Expand Down

0 comments on commit 373717b

Please sign in to comment.