Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8884581
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T21:05:41+00:00 2026-06-14T21:05:41+00:00

This is my current render method on my level in my Libgdx game. I

  • 0

This is my current render method on my level in my Libgdx game. I am trying to draw a BitmapFont on my level’s top right corner but all I’m getting is a bunch of white boxes.

 @Override
    public void render(
            float delta ) {
        Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);

        this.getBatch().begin();

            //myScore.getCurrent() returns a String with the current Score
        font.draw(this.getBatch(), "Score: 0" + myScore.getCurrent(), 600, 500);
        stage.act(Gdx.graphics.getDeltaTime());
        stage.draw();
        this.getBatch().end();
        }

I would like to add the score font into some kind of an actor and then do a scene.addActor(myScore) but I don’t know how to do that.
I followed Steigert’s tutorial to create the main game class that instantiates the scene, font, in the AbstractLevel class that is then extended by this level.

So far, I’m not using any custom font, just the empty new BitmapFont(); to use to default Arial font. Later I would like to use my own more fancy font.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T21:05:42+00:00Added an answer on June 14, 2026 at 9:05 pm

    Try moving the font.draw to after the stage.draw. Adding it to an actor would be very simple, just create a new class and Extend Actor Like such

    import com.badlogic.gdx.graphics.g2d.BitmapFont;
    import com.badlogic.gdx.graphics.g2d.SpriteBatch;
    import com.badlogic.gdx.scenes.scene2d.Actor;
    
    public class Text extends Actor {
    
        BitmapFont font;
        Score myScore;      //I assumed you have some object 
                            //that you use to access score.
                            //Remember to pass this in!
        public Text(Score myScore){
            font = new BitmapFont();
                font.setColor(0.5f,0.4f,0,1);   //Brown is an underated Colour
        }
    
    
        @Override
        public void draw(SpriteBatch batch, float parentAlpha) {
             font.draw(batch, "Score: 0" + myScore.getCurrent(), 0, 0);
             //Also remember that an actor uses local coordinates for drawing within
             //itself!
        }
    
        @Override
        public Actor hit(float x, float y) {
            // TODO Auto-generated method stub
            return null;
        }
    
    }
    

    Hope this helps!

    Edit 1:
    Also try System.out.println(myScore.getCurrentScore()); Just to make sure that that isn’t the issue. You can just get it to return a float or an int and when you do the "Score:"+ bit it will turn it into a string itself

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm running code that sometimes yields this: UInt32 current; int left, right; ... //sometimes
all I follow this http://msdn.microsoft.com/en-us/library/ka0yazs1.aspx to create an application and would like to draw
This method works OK, but if I add delayed_job's handle_asychronously, I get can't convert
I'm trying to manually draw a line in WPF by overriding the OnRender method
I am creating an app in backbone. This current code works but now I
We have this current database which we need to replace some tables by anther
What is current directory of shell script? Is this current directory from which I
I am having a bit of difficulty with this current code I have set
I have a variable declared at the top of my function as this.current_test =
As a beginner in Ocaml, I have this current working code: ... let ch_in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.