kadv

Dragging Example

Recommended Posts

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;			}		}

 

  1.  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?
  2. What exactly is this.position on the sprite -- is it the anchor point, or top-left corner?

 

Thanks for your help.

Share this post


Link to post
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.