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

  • SEARCH
  • Home
  • 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 7659141
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:17:37+00:00 2026-05-31T13:17:37+00:00

Im testing libgdx but I’m getting stuck in user input handling. My first attempt

  • 0

Im testing libgdx but I’m getting stuck in user input handling.

My first attempt was using Gdx.input directly from render method but I feel like reinventing the wheel cause I’m writing a lot of code to detect the input area when I get touch events.

I’m almost sure a better way should be using Actor class but there’s something I must be doing wrong becase the events never fire.

Here’s my code:

...
    Texture texture = new Texture(Gdx.files.internal("assets/sprite-sheet.png"));
            singlePlayerButton = new Image("SinglePlayerButton", new TextureRegion(texture,0,0,50,50)){

                @Override
                public boolean touchDown(float x, float y, int pointer) {
                    // TODO Auto-generated method stub
                    System.out.println("touch down");
                    return super.touchDown(x, y, pointer);
                }

                @Override
                public void touchUp(float x, float y, int pointer) {
                    System.out.println("touch up");             
                }

            };

            stage.addActor(singlePlayerButton);
...

public void render(float delta) {
        // Clear the screen
        Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);           
        stage.draw();
        spriteBatch.end();
    }

The image displays well but it doesn’t matter how many times I click on it I never get the event fired. What am i missing? Register the event? I can’t find any addTouchListener() method in Stage or Actor class.

Thanks!

  • 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-05-31T13:17:37+00:00Added an answer on May 31, 2026 at 1:17 pm

    You have to register all input processors with libGDX. Stage implements InputProcessor, so you have to register it:

    @Override
    public void create() {
        //... initialization
    
        Gdx.input.setInputProcessor(stage);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im testing an in-app purchase using my iPhone on iOS5 but despite going to
Unit testing sounds great to me, but I'm not sure I should spend any
//Testing numbers for primality #include <iostream> #include <cmath> using namespace std; int main() {
When testing my app using Instruments -> Activity Monitor, I'm seeing a difference in
When testing scipy using the nose package using scipy.test() , the test fails under
In testing output values from procs, why does the final select @TestValOut return 0
Testing the migration from Plone 3.3 to Plone 4 for a large site resulted
[unit testing newbie] [c#] Consider the following scenario: I'm using Silverlight and calling a
Testing a text-to-speech engine is a rather daunting task. The engine itself parses input
Testing several plus feeds - Made my own app from this post which gives

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.