Ejemplo n.º 1
0
 @Override
 public void draw(Graphics g) {
   if (this.body != null) {
     this.body.draw(g);
     for (Element element : this.elements) {
       element.draw(g);
     }
   }
 }
Ejemplo n.º 2
0
 @Override
 public Object isOnFocus(float x, float y) {
   for (Element element : this.elements) {
     if (element.isOnFocus(x, y) != null) {
       if (!element.isEmpty()) {
         return element;
       }
     }
   }
   if (body.isOnFocus(x, y)) {
     return null;
   }
   return null;
 }
Ejemplo n.º 3
0
  @Override
  protected void updatePosition() {
    if (this.body != null) {
      float currentX = this.body.getMinX();
      float currentY = this.body.getMaxY();

      for (Element element : this.elements) {
        if (currentY - element.getAbsoluteHeight() >= this.body.getMinY()) {
          currentY -= element.getAbsoluteHeight();
          element.setBody(
              new ColorRect(
                  new Rectangle(
                      currentX, currentY, this.body.getSizeX(), element.getAbsoluteHeight())));
        } else {
          element.setBody(
              new ColorRect(
                  new Rectangle(-1f, -1f, this.body.getSizeX(), element.getAbsoluteHeight())));
        }
      }
      this.changed = false;
    }
  }