Skip to content

Commit

Permalink
[Closes #616] Child actors should be updated
Browse files Browse the repository at this point in the history
  • Loading branch information
kamranayub committed Aug 4, 2016
1 parent 056b1cf commit ae0379d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/engine/Actor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1166,6 +1166,11 @@ module ex {
for (var trait of this.traits) {
trait.update(this, engine, delta);
}

// Update child actors
for (var i = 0; i < this.children.length; i++) {
this.children[i].update(engine, delta);
}

this.eventDispatcher.emit('update', new UpdateEvent(delta));
this.emit('postupdate', new PostUpdateEvent(engine, delta, this));
Expand Down
13 changes: 13 additions & 0 deletions src/spec/ActorSpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -912,6 +912,19 @@ describe('A game actor', () => {
expect(fixed.pos.x).toBe(0);
expect(fixed.pos.y).toBe(50);
});

it('updates child actors', () => {
var parentActor = new ex.Actor();
var childActor = new ex.Actor();
scene.add(parentActor);
parentActor.add(childActor);

spyOn(childActor, 'update');

scene.update(engine, 100);

expect(childActor.update).toHaveBeenCalled();
});

it('draws visible child actors', () => {
var parentActor = new ex.Actor();
Expand Down

0 comments on commit ae0379d

Please sign in to comment.