0

I have a Rectangle variable and when i click on it using

if(Gdx.input.isButtonPressed(Input.Buttons.LEFT)){"Dont know what to do here"}

I want to recognize that rectangle and do something on it. How can I do that?

pMpC
  • 257
  • 3
  • 14

1 Answers1

0

You are checking if mouse button is pressed and trying to search the rectangle it hit.

Libgdx already does that for you in scene2d.

You can create a Button instead of that rectangle and use a ClickListener on it in stead.


Reference:

How to create a button in Libgdx?


Hope this helps.
Good luck.

Community
  • 1
  • 1
Tanmay Patil
  • 6,882
  • 2
  • 25
  • 45
  • I created this variable: ImageButton b; and initialized it at create method: b = new ImageButton(); How can i import the image to that button now? – pMpC Jan 14 '15 at 13:00