I am using LibGdxthe LibGDX library to render 3da 3D model in my Android Applicationapplication. Now i, I am stuck, where iI want to render multiple dynamic texttexts on to different 3D boxes located on different coordinatedcoordinates of the screen. I am able to render a single text using SpriteBatchSpriteBatch, but iI need to render different string values on different boxes.
` SpriteBatch spriteBatch = new SpriteBatch(); BitmapFont font = new BitmapFont(); spriteBatch.maxSpritesInBatch = 5; spriteBatch.setProjectionMatrix(camera.combined.cpy().scale(camera.combined.cpy().getScaleX()/25,camera.combined.cpy().getScaleY()/25, 0.8f)); spriteBatch.begin();
SpriteBatch spriteBatch = new SpriteBatch();
BitmapFont font = new BitmapFont();
spriteBatch.maxSpritesInBatch = 5;
spriteBatch.setProjectionMatrix(camera.combined.cpy().scale(camera.combined.cpy()
.getScaleX()/25,camera.combined.cpy().getScaleY()/25, 0.8f));
spriteBatch.begin();
font.setColor(1.0f, 0.0f, 0.0f, 1.0f);
float xPos = -90;
int count = 0;
for (Widget widgets :
display.getWidgets()) {
{
float boxWidth = widgets.getBounds().getWidth();
float boxHeight = widgets.getBounds().getHeight();
float boxHeightCenter = widgets.getBounds().getCenterY();
if(count==0) {
{
font.draw(spriteBatch, "Hello"+count, xPos, boxHeightCenter-25, boxWidth,
0, true);
boxWidth, 0, ++count;true);
}
++count;
}
else{
{
font.draw(spriteBatch, "Hello"+count, xPos+boxWidth, boxHeightCenter-25, boxWidth, 0, true);
xPosboxWidth, =0, xPos+boxWidth;true);
xPos = ++count;
xPos+boxWidth;
}
++count;
}
}
spriteBatch.end();`
The above code renders only one string value , while. While debugging, "for"the "for" loop is getting traversed. But, but no positive result is obtained. Will be thankful if i get a solution.How do I fix this?