Ejemplo n.º 1
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);
    }
  }
Ejemplo n.º 2
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;
 }
Ejemplo n.º 3
0
  public boolean colliding(AEntity entity) {

    if (shape != null && entity.shape != null) {
      return shape.intersects(entity.shape);
    }

    return false;
  }
Ejemplo n.º 4
0
  public boolean checkCollide(Shape s) {
    int minXTile = (int) (s.getMinX()) / TILESIZE;
    int maxXTile = (int) (s.getMaxX()) / TILESIZE;
    int minYTile = (int) (s.getMinY()) / TILESIZE;
    int maxYTile = (int) (s.getMaxY()) / TILESIZE;

    for (int x = minXTile; x <= maxXTile; x++) {
      for (int y = minYTile; y <= maxYTile; y++) {
        if (tileIntegrity[x][y] > 0
            && s.intersects(new Rectangle(x * TILESIZE, y * TILESIZE, TILESIZE, TILESIZE))) {
          return true;
        }
      }
    }

    return false;
  }