Esempio n. 1
0
 /**
  * Converts coordinates for this group to those of a descendant actor. The descendant does not
  * need to be a direct child.
  *
  * @throws IllegalArgumentException if the specified actor is not a descendant of this group.
  */
 public void localToDescendantCoordinates(Actor descendant, Vector2 localPoint) {
   Group parent = descendant.getParent();
   if (parent == null)
     throw new IllegalArgumentException("Child is not a descendant: " + descendant);
   // First convert to the actor's parent coordinates.
   if (parent != this) localToDescendantCoordinates(parent, localPoint);
   // Then from each parent down to the descendant.
   descendant.parentToLocalCoordinates(localPoint);
 }
    @Override
    public void clicked(InputEvent event, float x, float y) {
      Vector2 point = new Vector2(x, y);
      Group g = (Group) event.getListenerActor();
      if (g.isAscendantOf(ColorSelectorPopup.this)) {
        point = g.localToDescendantCoordinates(ColorSelectorPopup.this, point);

        if (ColorSelectorPopup.this.getParent() != null
            && ColorSelectorPopup.this.hit(point.x, point.y, true) == null) {
          ((BoardActor) (ColorSelectorPopup.this.getParent()))
              .removeFromActor(ColorSelectorPopup.this);
          event.getListenerActor().removeListener(this);
        }
      }
    }