roxor45 Posted March 25, 2019 Share Posted March 25, 2019 hi all , I have make some button in my script for show/hide some object like that : var background = PIXI.Sprite.fromImage('images/sol2.jpg'); app.stage.addChild(background); var varbg = 1; function backg() { if (varbg < 1) { app.stage.addChild(background); varbg = 1; } else { (varbg > 0) app.stage.removeChild(background); varbg = 0 ; } } in the beginning my other object ( like bunny) , it's in front of the background. When I clic on button for hide background, it's ok my background disapear like a charm . but when a REclick on my button for show the background , my background reapear on the front of the canvas , Over my other object . So, my question is : It's possible to add a deep level at a child ? thanks for your help Quote Link to comment Share on other sites More sharing options...
botmaster Posted March 25, 2019 Share Posted March 25, 2019 That's what addChild does, put the object at the highest display list index. If you need to control where the object goes then use addChildAt or equivalent methods. Quote Link to comment Share on other sites More sharing options...
Exca Posted March 26, 2019 Share Posted March 26, 2019 In this case you could also just say .visible = false / true to keep layering constant. roxor45 1 Quote Link to comment Share on other sites More sharing options...
roxor45 Posted March 26, 2019 Author Share Posted March 26, 2019 7 hours ago, Exca said: In this case you could also just say .visible = false / true to keep layering constant. thanks for this idea ! it's work ! function backg() { if (varbg < 1) { background.visible = true; varbg = 1; } else { (varbg > 0) background.visible = false; varbg = 0 ; } } Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted March 26, 2019 Share Posted March 26, 2019 I prefer "renderable=false" because visible turns off some of teatures like "toLocal" method. Quote Link to comment Share on other sites More sharing options...
roxor45 Posted March 26, 2019 Author Share Posted March 26, 2019 1 hour ago, ivan.popelyshev said: I prefer "renderable=false" because visible turns off some of teatures like "toLocal" method. thanks for the tips Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.