Jump to content

Issue rotating DisplayObjectContainer (My sprite inside it warps)


Recommended Posts

First it's best if I give some background...


I have a single rectangular sprite.  This sprite is a photograph, when loading this photograph as a texture we first draw it to a canvas stretching it to become the nearest power of 2 texture.


Then in Pixi, we load the texture from the canvas and set the width/height properties of the sprite in order to return the sprite to the correct aspect ratio for the photograph.


This photogaph needs to be rotated around an dynamic origin point which is controlled by the user.


In order to achieve this we first began manipulating the sprite.anchor properties. which of course ended up effecting the position of the sprite itself (which we do not want).


Therefore we created a DisplayObjectContainer, set the sprite to be a child of that, and change the rotation of the container itself. Meaning that we can correctly manipulate the containers pivot point while leaving the sprite itself in its correct position.


This all works perfectly except that when the container is rotated, our sprites height/width change.  The attached photos show the issue:








Now... we have been able to hack around the problem by changing the scale.x and scale.y of the DisplayObjectContainer to set the photo to its correct aspect ratio, while setting the sprites scale factors to 1.


Although this works we are then left with a set of controls (which are not inside the container as they need to remain static) in a totally different transformation/coordinate space than the the photo itself, which makes writing positioning and other calculations extremely difficult and has proved to be a huge headache for us.


So.... my question is how can I keep the width/height properties on the sprite static, while rotating its parent DisplayObjectContainer?

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...