Jump to content

Drag and drop with rotated sprites


Recommended Posts



I'm relatively new to Pixi.


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



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:



Here without rotation:



Thanks in advance!



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.

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.


  • Recently Browsing   0 members

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