0
\$\begingroup\$

I want to implement my own widget, here is an image:enter image description here

what I want to get. Instead of numbers there will be some names, but I think it doesn't matter. I'm pretty new in libGDX, so could you please briefly describe me plan, how can I do something like this (if there will be some code, it would be awesome)? I tried to google it, but didn't find something relevant.

Thanks in advance!

\$\endgroup\$
1
\$\begingroup\$
 shapeRenderer.begin(ShapeType.Line);
 shapeRenderer.setColor(1, 1, 0, 1);
 shapeRenderer.line(x, y, x2, y2);
 shapeRenderer.rect(x, y, width, height);
 shapeRenderer.circle(x, y, radius);
 shapeRenderer.end();

Here is an example for the shapeRenderer class. I think that tree is a dynamic, a background image wouldn't work.

So you need to come up with an object oriented design or use a recursive function to draw it. How do you store your data? Without further information, supplying you with code is impossible.

Also did you get that image in libgdx, and are you asking to only write words instead of numbers? If that's the case use bitmap font. To use bitmap font look at the first link.

Here are some links to help you.

https://github.com/libgdx/libgdx/wiki/Gdx-freetype

https://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/glutils/ShapeRenderer.html

\$\endgroup\$
0
\$\begingroup\$

People might hate me for this (Not the most optimized idea, but still easy):

You can create an image without the numbers/names, just the lines, load it as background image, then write your text (Doesn´t matter if numbers or letters) in the desired position.

yourGame.font.draw(yourBatch, yourString, x, y);

(Take into account the resolution of the image if you want your app to work on different devices)

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.