Reputation: 157
I'm trying to add Actor
to Stage
and that actor image's shape is Circle
. I want to detect the touch only in that circle not the rectangle. How could I accomplish that ?
A bit of backstory:
I had made UI from Sprites
, and it was working fine. But now I want to change that system to Scene2D.UI
( it's easier to manipulate this way ( at least for me ) ).
Thanks in advance!
Upvotes: 1
Views: 137
Reputation: 157
You just need to @Override the Actor's hit method, like so:
@Override public Actor hit( float x, float y, boolean touchable )
{
if( touchable && getTouchable( ) != Touchable.enabled ) return null;
return area.contains( x, y ) ? this : null;
}
P.S. area is a Circle class object, defined in the Constructor
Upvotes: 3