コード例 #1
0
 public static boolean internalIntersects(Shape shape1, Shape shape2) {
   TimingInfo.CURRENT_TIMING_INFO.getCounter("GeometryUtils.intersects").record(1);
   if (shape1.intersects(shape2)) return true;
   if ((shape1 instanceof Rectangle && shape2 instanceof Circle)
       || (shape2 instanceof Rectangle && shape1 instanceof Circle)) {
     Circle c;
     Rectangle r;
     if (shape1 instanceof Circle) {
       c = (Circle) shape1;
       r = (Rectangle) shape2;
     } else {
       c = (Circle) shape2;
       r = (Rectangle) shape1;
     }
     if (r.contains(c.getCenterX(), c.getCenterY())) {
       return true;
     }
   }
   if (shape2 instanceof Line) {
     return shape1.contains(shape2);
   }
   if (shape1 instanceof Line) {
     return shape2.contains(shape1);
   }
   return false;
 }
コード例 #2
0
  public void mouseClicked(int na, int x, int y, int clickCount) {
    for (MKSpriteNode node : buttons) {
      for (MKPhysicsBody body : node.getPhysicsBodies()) {
        Shape rigidBody = body.getBody();
        if (rigidBody.contains(mouseShape) || rigidBody.intersects(mouseShape))
          this.setDisplayTo(node);
      }
    }

    for (MKPhysicsBody body : playButton.getPhysicsBodies()) {
      Shape rigidBody = body.getBody();
      if (rigidBody.contains(mouseShape) || rigidBody.intersects(mouseShape))
        this.moveToGameWithPlayer(displayRacer);
    }
  }
コード例 #3
0
ファイル: MouseOverArea.java プロジェクト: alxyuu/tractorcg
  /**
   * Create a new mouse over area
   *
   * @param container The container displaying the mouse over area
   * @param image The normalImage to display
   * @param shape The shape defining the area of the mouse sensitive zone
   */
  public MouseOverArea(GUIContext container, Image image, Shape shape) {
    super(container);

    area = shape;
    normalImage = image;
    currentImage = image;
    mouseOverImage = image;
    mouseDownImage = image;

    currentColor = normalColor;

    state = NORMAL;
    Input input = container.getInput();
    over = area.contains(input.getMouseX(), input.getMouseY());
    mouseDown = input.isMouseButtonDown(0);
    updateImage();
  }
コード例 #4
0
ファイル: MouseOverArea.java プロジェクト: alxyuu/tractorcg
 /** @see org.newdawn.slick.util.InputAdapter#mouseReleased(int, int, int) */
 public void mouseReleased(int button, int mx, int my) {
   over = area.contains(mx, my);
   if (button == 0) {
     mouseDown = false;
   }
 }
コード例 #5
0
ファイル: MouseOverArea.java プロジェクト: alxyuu/tractorcg
 /** @see org.newdawn.slick.util.InputAdapter#mousePressed(int, int, int) */
 public void mousePressed(int button, int mx, int my) {
   over = area.contains(mx, my);
   if (button == 0) {
     mouseDown = true;
   }
 }
コード例 #6
0
ファイル: MouseOverArea.java プロジェクト: alxyuu/tractorcg
 /** @see org.newdawn.slick.util.InputAdapter#mouseMoved(int, int, int, int) */
 public void mouseMoved(int oldx, int oldy, int newx, int newy) {
   over = area.contains(newx, newy);
 }