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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T11:39:23+00:00 2026-06-04T11:39:23+00:00

here’s my sample from the libgdx android game that I want to create. Nothing

  • 0

here’s my sample from the libgdx android game that I want to create. Nothing special yet, cause I’m just starting my adventure with Android games.

Here is a couple of questions I would like to get answered

So far I am using the Gdx.input.isTouched function and check if that matches the bunny coordinates, I do that for each bunny and at the end I would like to have 11 of them and that’s just too much to write. Is there a way to check if the Image class from import com.badlogic.gdx.scenes.scene2d.ui.Image; was touched? Or else does the Actor class has that feature?

Another thing is that when I instantiate the bunny class and I click the bunny, all of them are changing to “scared”. It’s because the Scene2d.Image texture has to be static. Is there a way to change that?

if(Gdx.input.isTouched()){  

            x = Gdx.input.getX();  
            y = Gdx.graphics.getHeight() - Gdx.input.getY();


         // **** Show Coordinates **** \\ 
            if (x < 420)
                font.draw(batch, "x:" + x + 
                    "\n y: " + y, x, y);
            else
                font.draw(batch, "x:" + x + 
                        " y: " + y, x-65, y);
         // **** End Show Coordinates **** \\

            //if krolik (bunny) is touched add highscore and change texture to scared
            if (x >= krolik.pos.x && y >= krolik.pos.y
                    && x <= krolik.pos.x + 64 && y <= krolik.pos.y + 64)
            {   
                krolik.scared();
                highscore+=100;
            }
            else if (x >= krolik2.pos.x && y >= krolik2.pos.y
                    && x <= krolik2.pos.x + 64 && y <= krolik2.pos.y + 64)
            {   
                krolik2.scared();
                highscore+=100;
            }
       } 
        else{

        krolik.normal();

        }
        // **** Show Highscore **** \\ 
        font.draw(batch, "Highscore: " + highscore, 350, 300);
        batch.draw(krolik.getTexture(), krolik.pos.x, krolik.pos.y);
        batch.draw(krolik2.getTexture(), krolik2.pos.x, krolik2.pos.y);
            batch.end();
  • 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-04T11:39:25+00:00Added an answer on June 4, 2026 at 11:39 am

    Why is it that you are using Image but not drawing with Stage? Image and other Actors are for using Stage which can take care of your touch events and drawing very easily.

    Create them like this:

    for (int i = 0; i < KROLIKS_COUNT; i++) {
        final Image krolik = new Image(nonScaredTextureRegion);
        krolik.setClickListener(new ClickListener() {
            @Override
            public void click(Actor actor, float x, float y) {
                krolik.setRegion(scaredTextureRegion);
                highscore+=100;
            }
        });
        krolik.x = startPosX;
        krolik.y = startPosY;
        stage.addActor(krolik);
    }
    

    set the stage as the input processor:

    Gdx.input.setInputProcessor(stage);
    

    then in render, simply:

    stage.act(Gdx.graphics.getDeltaTime());
    stage.draw();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is a complete example. I want to forbid using A::set from objects casted
Here's a query that works fine: SELECT rowid as msg_rowid, a, b, c FROM
Here is a sample of text that I’m working with: Word1 Word2 ... Word4
Here is what I am trying to do: Create a global gesture container that
Here's the deal: I'm in the process of planning a mid-sized business application that
Here's what I want to do: Given a table PeopleOutfit (id int primary key,
Here's the method. I want to know if I am violating any best practices
Here's my procedure: DROP PROCEDURE IF EXISTS `couponExpires`$$ CREATE DEFINER=`root`@`localhost` PROCEDURE `couponExpires`(IN couponID BIGINT,
Here is my problem : I have a post controller with the action create.
Here is an example. foreach (var doc in documents) { var processor = this.factory.Create();

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.