Pixi.js: PIXI.Text cant be displayed when add to a child container

Created on 30 Oct 2016  ·  3Comments  ·  Source: pixijs/pixi.js

take http://pixijs.github.io/examples/#/demos/text-demo.js for example,

I added a container named view to stage,
1

and add textSample to view,
2

then, the textSample won't be displayed, is it correct or a bug?

🤔 Question

Most helpful comment

It's correct.. and the reason is the ordering of the children.

You see, within the init() function you have

// add a shiny background...
var background = PIXI.Sprite.fromImage('required/assets/textDemoBG.jpg');
stage.addChild(background);

This background is added _after_ your new view container is added, and so will be drawn after anything added to your new view container.
If you move the

var view = new PIXI.Container();
stage.addChild(view)

to just before
view.addChild(textSample);
You'll see it works just fine :)

All 3 comments

It's correct.. and the reason is the ordering of the children.

You see, within the init() function you have

// add a shiny background...
var background = PIXI.Sprite.fromImage('required/assets/textDemoBG.jpg');
stage.addChild(background);

This background is added _after_ your new view container is added, and so will be drawn after anything added to your new view container.
If you move the

var view = new PIXI.Container();
stage.addChild(view)

to just before
view.addChild(textSample);
You'll see it works just fine :)

got it, thanks a lot.

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Vardner picture Vardner  ·  3Comments

Darker picture Darker  ·  3Comments

YuryKuvetski picture YuryKuvetski  ·  3Comments

readygosports picture readygosports  ·  3Comments

distinctdan picture distinctdan  ·  3Comments