(CGA) Checking for Collisions Lesson
Checking for Collisions
The Actor class has a method to check for collisions.
protected Actor getOneIntersectingObject(Java.lang.Class cls)
This method is a return method. It will return the actor of the class passed through the parameter that intersects with the Object. Look at the description from the Actor API below.
The parameter is passed the class of objects to look for or null if you want all objects.
You can combine this with an if statement to make something happen when the object intersects with another object.
Access the learning object below to see how the method is used.
Stopping the World
The Greenfoot class has a method called stop(). This will pause the execution of the game.
Remember the Greenfoot class is a static class. You must use the class name to call the method.
Greenfoot.stop();
[CC BY 4.0] UNLESS OTHERWISE NOTED | IMAGES: LICENSED AND USED ACCORDING TO TERMS OF SUBSCRIPTION