Jump to content

getLocalPosition in response to mouse events seems to swap x and y


Arkless
 Share

Recommended Posts

First off, PIXI is incredibly new to me so the problem might lie in my incompetence.

What I did:


        var localOffset = mouseData.data.getLocalPosition(mouseData.data.target);
        console.log(JSON.stringify(localOffset));

mouseData being the input of multiple different mouse events (mousedown, mouseup, rightdown, rightup, mouseover)

The rotation of my sprite is set to 0.

 

What happens:

The console prints {x:xval, y:yval} where xval changes when moving up/down and yval changes when moving rigth/left. 

As far as I can tell, everything else seems to work with x increasing towards the right and y increasing towards the bottom of the screen. I can easily work around this but it felt report worthy.

 

 

Additional stuff that might be of interest:

The local position seems to be correctly offsetted by the anchor.

What feels wrong to me is that the distance does not take into account the width/height of the actual sprite, only the width/height of the texture being used. 

This might actually be working as intended but is not what I expected.

 

Have a nice day,

 - Michael

 

 

Ok, so it gets weirder (for me).

To make sure no rotation data is screwing with me I hardcoded the rotation to different values. Rotation does not seem to influence my results.

x and y are not only swapped, the sign of x (value found in y) is also inverted

I get the expected values when using a PIXI.Container() instead of a sprite (no xy swap, no inverted sign).

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