Jump to content

`getBounds` get wrong coordinate


Recommended Posts

In my code, I use center as 0, 0.

My other coordinate are all right, but when I use `getBounds` to get a curve's bound, the return value is incorrect.

It seems the x,y is relative to top-left instead of center.


Why? How can I get the correct coordinate?

Link to comment
Share on other sites

Using the top left corner as the origin is common for 2D computer graphics, but you can convert the bounds like this:

var bounds = sprite.getBounds();

bounds.x -= renderer.width  / 2;
bounds.y -= renderer.height / 2;


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