kadv Posted June 16, 2013 Share Posted June 16, 2013 Hello, Been playing with the dragging example in pixi.js (example 8), my questions are around the following snippet (line 82: index.html): bunny.mousemove = bunny.touchmove = function(data) { if(this.dragging) { // need to get parent coords.. var newPosition = this.data.getLocalPosition(this.parent); this.position.x = newPosition.x; this.position.y = newPosition.y; } } Why do we need the parent position, as in will it be different to the sprite's dragged position over some common area? Are children's coordinate space relative to the parent rather than something like the global stage? What exactly is this.position on the sprite -- is it the anchor point, or top-left corner? Thanks for your help. Quote Link to comment Share on other sites More sharing options...
xerver Posted June 16, 2013 Share Posted June 16, 2013 1) Yes, position is relative to an object's parent 2) The anchor point defaults to the top left corner, but can be changed via the `anchor` property. Quote Link to comment Share on other sites More sharing options...
kadv Posted June 17, 2013 Author Share Posted June 17, 2013 Thanks, rolnaaba. Sorry to confirm this position thing several times (inadvertently, since my questions are related) . Quote Link to comment Share on other sites More sharing options...
xerver Posted June 17, 2013 Share Posted June 17, 2013 Not a problem, thats what the forums are for! 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.