Home:ALL Converter>libGDX Scene2d - Use screen units to draw text on world coordinates

libGDX Scene2d - Use screen units to draw text on world coordinates

Ask Time:2017-06-13T18:25:46         Author:Mofe Ejegi

Json Formatter

Recently began learning scene2d and developed a card game with it. I used world units for my coordinate system whereby one card width is 1f. The center of the screen is (0, 0) using world units. Now I'm trying to draw a label on the center card placed at (1,0) but it's showing extremely large, no matter how much i scale the font, and i can't scale less than 0.05f.

I did extensive research and found out here that i can use camera.project for this, tried but couldn't work quite well. I'd appreciate any examples.

The goal is to temporarily project my world coordinates to screen coordinates, draw the text at the required position and with the correct size(in screen pixels), then unproject the stage back to world units, and continue further processes.

I'd show code if asked to, but i really just require some guidance here.

Author:Mofe Ejegi,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/44518839/libgdx-scene2d-use-screen-units-to-draw-text-on-world-coordinates
yy