Voobus Posted September 15, 2015 Share Posted September 15, 2015 Hey guys, I'm trying to manage component children/parent references on my own, and I can't seem to get it to render with coordinates properly. First off, I have a Scene that extends the container. The scene has a player property (the player's parent property is set to the scene). In the scene's render method, I have it render the player, instead of looping through and rendering each childclass Scene extends Pixi.Container { __player__ = new Pixi.Container(); renderWebGL (renderer) { this.__player__.renderWebGL(renderer); }}As you can see, the player is another container, and I repeat the process, but I add a __sprite__ to the player. What I get on the screen is that the player is rendering just fine to the scene, but when I adjust the x,y coordinates of the player container, it doesn't move. I've also tried setting the x,y of the sprite that lives inside of the player container. tl;dr if I set the parent property of a component, is that good enough when trying to render something relative to a parent? Quote Link to comment Share on other sites More sharing options...
xerver Posted September 15, 2015 Share Posted September 15, 2015 Do you have a running example I can debug, what you posted seems like it should work in isolation. Quote Link to comment Share on other sites More sharing options...
Voobus Posted September 15, 2015 Author Share Posted September 15, 2015 Do you have a running example I can debug, what you posted seems like it should work in isolation. http://jsfiddle.net/emw7ps9o/11/ If you scroll down to line 40, you can see that I'm passing in an x,y of 100,100. This should make the player container acquire those coordinates, but as you can see, it still draws it at 0,0 Quote Link to comment Share on other sites More sharing options...
xerver Posted September 15, 2015 Share Posted September 15, 2015 Your transforms aren't being updated properly. https://github.com/pixijs/pixi.js/blob/master/src/core/display/Container.js#L319-L332 You don't override that, so it updates the children array, which for you isn't a thing. Quote Link to comment Share on other sites More sharing options...
Voobus Posted September 16, 2015 Author Share Posted September 16, 2015 Yes! That was exactly the problem; thanks! 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.