Skip to content

Commit

Permalink
Merge pull request #528 from excaliburjs/refactor-add-child
Browse files Browse the repository at this point in the history
Actor.addChild() is now Actor.add()
  • Loading branch information
eonarheim committed Oct 1, 2015
2 parents d1fd4aa + ff5c279 commit 8ab63ff
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions sandbox/web/src/game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,12 @@ player.rotation = 0;

// Health bar example
var healthbar = new ex.Actor(0, -70, 140, 5, new ex.Color(0, 255, 0));
player.addChild(healthbar);
player.add(healthbar);

// Add Title above player
var playerLabel = new ex.Label('My Player', -70, -69, null, spriteFont);

player.addChild(playerLabel);
player.add(playerLabel);

// Retrieve animations for player from sprite sheet
var left = spriteSheetRun.getAnimationBetween(game, 1, 11, 50);
Expand Down
4 changes: 2 additions & 2 deletions src/engine/Actor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ module ex {
* move with it.
* @param actor The child actor to add
*/
public addChild(actor: Actor) {
public add(actor: Actor) {
actor.collisionType = CollisionType.PreventCollision;
if (ex.Util.addItemToArray(actor, this.children)) {
actor.parent = this;
Expand All @@ -509,7 +509,7 @@ module ex {
* Removes a child actor from this actor.
* @param actor The child actor to remove
*/
public removeChild(actor: Actor) {
public remove(actor: Actor) {
if (ex.Util.removeItemToArray(actor, this.children)) {
actor.parent = null;
}
Expand Down
2 changes: 1 addition & 1 deletion src/engine/Particles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ module ex {
*
* // add the emitter as a child actor, it will draw on top of the parent actor
* // and move with the parent
* actor.addChild(emitter);
* actor.add(emitter);
*
* // or, alternatively, add it to the current scene
* engine.add(emitter);
Expand Down
14 changes: 7 additions & 7 deletions src/spec/ActorSpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,7 @@ describe('A game actor', () => {
expect(childActor.x).toBe(50);
expect(childActor.y).toBe(50);

actor.addChild(childActor);
actor.add(childActor);

actor.moveBy(10, 15, 1000);
actor.update(engine, 1000);
Expand Down Expand Up @@ -831,8 +831,8 @@ describe('A game actor', () => {
var child = new ex.Actor(0, 0, 100, 100);
var child2 = new ex.Actor(-600, -100, 100, 100);

parent.addChild(child);
child.addChild(child2);
parent.add(child);
child.add(child2);

// check reality
expect(parent.contains(550, 50)).toBeTruthy();
Expand All @@ -854,14 +854,14 @@ describe('A game actor', () => {
var parent = new ex.Actor(0, 0, 100, 100);
var child = new ex.Actor(100, 100, 100, 100);
var child2 = new ex.Actor(100, 100, 100, 100);
parent.addChild(child);
parent.add(child);

expect(parent.contains(150, 150)).toBeFalsy();
expect(child.contains(150, 150)).toBeTruthy();
expect(parent.contains(150, 150, true)).toBeTruthy();
expect(parent.contains(200, 200, true)).toBeFalsy();

child.addChild(child2);
child.add(child2);
expect(parent.contains(250, 250, true)).toBeTruthy();
});

Expand Down Expand Up @@ -901,7 +901,7 @@ describe('A game actor', () => {
var parentActor = new ex.Actor();
var childActor = new ex.Actor();
scene.add(parentActor);
parentActor.addChild(childActor);
parentActor.add(childActor);

spyOn(childActor, 'draw');

Expand All @@ -914,7 +914,7 @@ describe('A game actor', () => {
var parentActor = new ex.Actor();
var childActor = new ex.Actor();
scene.add(parentActor);
parentActor.addChild(childActor);
parentActor.add(childActor);

spyOn(childActor, 'draw');

Expand Down

0 comments on commit 8ab63ff

Please sign in to comment.