[GREENFOOT-389] Add canSee/eat equivalents to Actor
I would like to add convenience methods for canSee/eat to Greenfoot. They are quite common use cases, and even though they can be accomplished using the existing methods (just like move() and turn() could be), I think it would help beginners to get started if we have them as methods. I propose:
{noformat} boolean touchingAny(Class clazz) { return getOneIntersectingObject(clazz) != null; }
void removeAllTouching(Class clazz) { World world = getWorld(); if (world != null) throw new IllegalStateException("Cannot remove touching objects while not in world"); world.removeObjects(getIntersectingObjects(clazz)); } {noformat}
Issue metadata
- Issue type: Task
- Priority: Medium
- Fix versions: 2.3.0