76
Graphics / RenderTarget::ConvertCoords backwards
« on: September 25, 2011, 01:19:05 am »
I wanted to draw some text in RenderWindow that would be positioned near a sprite, like a label or tag always moving along with the sprite, attached to some point of it and not rotating or scaling regardless of sprite's transformations. And I was really surprised to not find a complementary function to ConvertCoords, that would convert world coordinates to screen coordinates. I believe this to be a frequently occuring task and i guess it is only reasonable to add such functionality to RenderTarget
The ConvertCoords(x, y, view = NULL) function takes x and y global coordinates and transforms them into view coordinates given the current view attached to the render window.
I think the functionality you wanted was to get the sprite's coordinates in terms of where it will be drawn on the screen. It wouldn't make much sense to have a function for sprite saying Sprite::ConvertCoords(view), meaning, you pass in a view and get it's coordinates out in terms of the view. (You could call it, GetPositionInView or something.
What you really want to do is
as the window will have the view already attached to it.
The ConvertCoords(x, y, view = NULL) function takes x and y global coordinates and transforms them into view coordinates given the current view attached to the render window.
I think the functionality you wanted was to get the sprite's coordinates in terms of where it will be drawn on the screen. It wouldn't make much sense to have a function for sprite saying Sprite::ConvertCoords(view), meaning, you pass in a view and get it's coordinates out in terms of the view. (You could call it, GetPositionInView or something.
What you really want to do is
Code: [Select]
Window.ConvertCoords(Sprite.GetX(), Sprite.GetY());
as the window will have the view already attached to it.