Collection<Actor> getObjectsAtPixel(int x, int y) { // This is a very naive and slow way of getting the objects at a given // pixel. // However, it makes sure that it doesn't use the collision checker // which we want to keep optimised. // It will be very slow with a lot of rotated objects. It is only used // when using the mouse to select objects, which is not a time-critical // task. List<Actor> result = new LinkedList<Actor>(); TreeActorSet objects = getObjectsListInPaintOrder(); for (Actor actor : objects) { Rect bounds = actor.getBoundingRect(); if (x >= bounds.getX() && x <= bounds.getRight() && y >= bounds.getY() && y <= bounds.getTop()) { if (actor.containsPoint(x, y)) { result.add(actor); } } } return result; }