Jump to content

Drag and drop with rotated sprites


fela98
 Share

Recommended Posts

Hi,

 

I'm relatively new to Pixi.

 

I have a problem similar to the one mentioned in this post:

http://www.html5gamedevs.com/topic/5766-bunny-drag-example-with-correct-mouse-offset/?hl=%2Bdrag+%2Bpixi

 

I used the code from the post and it worked seamlessly. However, when i began rotating the Sprites the offset became wrong, and the sprite jumps to another location when i begin dragging it. Do i have to use some trigonometric function to reverse the rotation? How can I do this?

 

Here is a version with rotation:

http://jsfiddle.net/cXfpq/2/

 

Here without rotation:

http://jsfiddle.net/dirkk0/cXfpq/

 

Thanks in advance!

 

Felix

Link to comment
Share on other sites

I think this is because you are using the value returned by calling the 'getLocalPosition' method of the interaction data. If you just use the iData.global property instead that gives you the position of the interaction relative to the stage, thereby ignoring any rotation transforms applied to the sprite itself.

Link to comment
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...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...