Adds the createEventListeners and intersects functions.
@@ -52,6 +52,14 @@ public class Component {
tiles = new TileGrid(dimensions, position);
}
+ /**
+ * Creates the event listeners.
+ *
+ * @param parentScreen
+ * The parent screen.
+ */
+ protected void createEventListeners(final @NonNull Screen parentScreen) {}
+
/**
* Draws the component onto a screen.
*
@@ -79,6 +87,26 @@ public class Component {
}
}
+ /**
+ * Determines whether or not a point intersects a tile grid.
+ *
+ * @param point
+ * The tile-based point position.
+ *
+ * @param tileGrid
+ * The tile grid.
+ *
+ * @return
+ * Whether or not the point intersects the tile grid.
+ */
+ protected boolean intersects(final Point point, final TileGrid tileGrid) {
+ boolean intersects = point.x >= tileGrid.getXPosition();
+ intersects &= point.x < (tileGrid.getWidth() + tileGrid.getXPosition());
+ intersects &= point.y >= tileGrid.getYPosition();
+ intersects &= point.y < (tileGrid.getHeight() + tileGrid.getYPosition());
+ return intersects;
+ }
+
/**
* Retrieves an unmodifiable version of the event listeners list.
*
