Reputation: 89
I use this code to move object:
if (Gdx.input.isTouched())
{
gameObject1.y=Gdx.graphics.getHeight()-Gdx.input.getY() + 30;
gameObject1.x=Gdx.input.getX() + 30;
}
But in this case, object move when screen is touched. In LibGdx is simple way to move object when this object is clickedd/pressed? Something like the code above?
Upvotes: 0
Views: 87
Reputation: 19776
The most simple way is probably to use scene2d
for this. It has a hit detection feature, based on an event system that you can use by attaching listeners to your Actors
.
Another way would be to use Intersector
in a combination with Rectangle
as your bounding box and do the hit detection yourself.
Upvotes: 1