This site requires JavaScript, please enable it in your browser!
Greenfoot back
Sirpancakeking
Sirpancakeking wrote ...

2017/3/21

How do you check if ClassA has touched ClassB from MyWorld

Sirpancakeking Sirpancakeking

2017/3/21

#
I am making a game and I simply want to check if ClassA touched ClassB from MyWorld so then when ClassA touches ClassB, the game ends and shows a screen that says game over on it. The method I am trying right now does not work as getOneIntersectingObject shows this under it: getOneIntersectingObject(java.lang.Class<?>) has protected access in greenfoot.Actor Pls help :p
Super_Hippo Super_Hippo

2017/3/21

#
Classes do not touch. Maybe instances of certain classes can touch. But it seems like you are already calling the method on an actor and not on a class (which is good). You can create a method in your ClassA (or B) to do the job for you:
public boolean touchingB()
{
    return isTouching(ClassB.class);
}
Then call this method instead.
You need to login to post a reply.