How can I use Actor.hit in libgdx . I want to know when two Actors collide through animation, is the Actor.hit method what I would use?
Asked
Active
Viewed 3,914 times
1 Answers
6
Please read the documentation: here
Hit is used for user input only, like touch and mouseevents. It is not how you detect collisions.
You would need to do that yourself with a Rectangle for example which you update like this:
private void updateBounds() {
bounds.set(getX(), getY(), getWidth(), getHeight());
}
Then you can easily check for collisions/overlaps with other Actors.

noone
- 19,520
- 5
- 61
- 76
-
@noone what if i have a single actor and it is circle , how can i detect touch only for the circular image. – ManishSB Aug 13 '14 at 04:43
-
then you need to override the hit method. How to check if the coordinate is in the circle: http://stackoverflow.com/questions/481144/equation-for-testing-if-a-point-is-inside-a-circle – noone Aug 13 '14 at 05:07