eddieone Posted June 8, 2016 Share Posted June 8, 2016 So I have a pineapple sprite I want behind the player. When I use sendToBack, it doesn't seem to do anything. What am I missing? this.pineapple = game.make.sprite(0, 0, 'pineapple'); this.pineapple.anchor.set(0.5); this.pineapple.x = 0; this.pineapple.y = - 60; this.sprite.addChild(this.pineapple); this.pineapple.sendToBack(); I also tried addChildAt(sprite, 0) though no luck Link to comment Share on other sites More sharing options...
rich Posted June 8, 2016 Share Posted June 8, 2016 It only works in Groups. Where-as you've added the Sprite as a child of another Sprite. Children of Sprites always render on the top of the parent, they can never render below it. If you need to do that, you need to use a Group (or a DisplayObjectContainer) eddieone 1 Link to comment Share on other sites More sharing options...
eddieone Posted June 8, 2016 Author Share Posted June 8, 2016 You are right. It is working but since my panda is also the parent it won't display behind that. If I understand correctly, groups don't work well with Box2D unless they're never moved. I will try to use a display object and render my panda as a child. Maybe setup my own layers, so I don't have to fuss with moving stuff once I start stacking a bunch of sprites. Thanks Rich Link to comment Share on other sites More sharing options...
eddieone Posted June 10, 2016 Author Share Posted June 10, 2016 For anyone who may find this, I ended up using a blank sprite. It provides the same thing as a display object without needing to figure out the underpinnings of Pixi. Link to comment Share on other sites More sharing options...
Recommended Posts