Skip to content

Commit

Permalink
animate through nested stage
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanpopelyshev committed Jan 6, 2018
1 parent d6af45c commit 615e1e7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/display/src/Stage.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ export default class Stage extends Container

onAnimate(delta)
{
this.emit('animate', delta);

this.innerStage.flushDetached();

this.runnerAnimate.run(delta);
Expand Down
17 changes: 17 additions & 0 deletions packages/display/test/Stage.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,5 +231,22 @@ describe('PIXI.Stage', function ()
expect(counter).to.be.equals(15);
expect(animated2.parentStage).to.be.null;
});

it('should work with nested stages', function ()
{
const stage1 = new Stage();
const container1 = new Container();
const stage2 = new Stage();
const animated1 = new Container();
let counter = 0;

animated1.onAnimate = (deltaTime) => { counter += deltaTime; };
stage1.addChild(container1);
container1.addChild(stage2);
stage2.addChild(animated1);

stage1.onAnimate(30);
expect(counter).to.be.equals(30);
});
});
});

0 comments on commit 615e1e7

Please sign in to comment.