Jump to content

Invert World Y coordinates


Recommended Posts



I'm having trouble with the current coordinate system.


The website I'm making is a platform-like "game", so I want the Y 0 world coordinate to be at the bottom of the canvas, not the top.


The way I've done it:

y = game.world.height - sceneSprite.y - sceneSprite.height;

But I find it very ugly. I just want assign 0 to the y coordinate so it positions at the bottom.


Can't find any documentation for inverting world coordinates, is there any way of doing this?

Link to comment
Share on other sites

This typical of computer-based coordinate systems and is present in pretty much every framework and system, including Flash. You may want to set the anchor.y of the sprite to 1, which will set its origin to the bottom, then you could create your own translation function though, something like this:

function invertY(y) {  return game.world.height - y;}sceneSprite.y = invertY(0);

You could even extend the sprite and make this all happen automatically, so the anchor would be set upon creating the extended sprite, and setting the y property of the sprite would automatically invert it as above.

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