Paumonsu Posted October 16, 2014 Share Posted October 16, 2014 Hello. 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 More sharing options...
lewster32 Posted October 16, 2014 Share Posted October 16, 2014 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 More sharing options...
Recommended Posts