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 7181703
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T17:36:46+00:00 2026-05-28T17:36:46+00:00

i want to show a picture, then wait for get input (i mean touch),

  • 0

i want to show a picture, then wait for get input (i mean touch), after that check it with position of picture. batch must be stay in alert for my input. but i don’t know where i must compare, input and position of pic. or how i must use wait, to create delay for get touch input.
for example, i use this code. but it just show black screen…

public void render() {
    x = rand.nextFloat() * 1024;
    y = rand.nextFloat() * 700;
    Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
    batch.begin();
    batch.draw(texture, x, y);
    if (Gdx.input.justTouched()) {
        if (Gdx.input.getX() > x && Gdx.input.getX() < texture.getWidth() + x) {
            if (Gdx.input.getY() > y && Gdx.input.getY() < texture.getHeight() + y) {
                batch.end();
            }
        }
    }
}

or use wait for create delay in show pic.

public void render() {
    x = rand.nextFloat() * 1024;
    y = rand.nextFloat() * 700;
    Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
    batch.begin();
    batch.draw(texture, x, y);
    try {
        batch.wait();
    } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    batch.end();
}

i just begin gdx and android. sorry for my bad language.

  • 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-28T17:36:47+00:00Added an answer on May 28, 2026 at 5:36 pm

    You don’t have to wait for input. Main application thread polls input events for you. If, for example, mouse button is pressed, then this event is polled and you can check if left mouse is currently pressed in your render() method and act accordingly. For example:

    public void render() {
      ...
      if(Gdx.input.isButtonPressed(Buttons.LEFT)) {
          //move sprite left
      }
    }
    

    However i think that better way is to use InputProcessor. Implement InputProcessor and register it:

    Gdx.input.setInputProcessor(yourInputProcessor);
    

    In this case, main application thread processes polled events, and calls InputProcessor’s callback methods.

    See:

    • InputProcessor JavaDoc
    • InputTest demo in Gdx-tests
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to take allow the user to take a picture and then show
I want to show no_picture.png if requested picture does not exists. I should do
I want show an information page after success db opartions. And after the info
I want show annotation view (above one of my pin) after load map. For
I want to make user upload his picture. After he selects the picture from
I am new to Android programming and Threads. I want to get a picture
hi i have childform and parent form I want to show picture in picturebox
I want to show the users profile picture in a list view. When I
I want to get a content page from Wiki in this format (the picture
I want to scale captured image and show it in the picture box which

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.