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

2015/4/9

Collisions between objects of the same class...

sergeantjackson sergeantjackson

2015/4/9

#
A friend and I are making a game with Greenfoot and I'm not going to lie it worked out pretty well so far. The problem is that enemies should not overlap other enemies from the same class. We have been looking for a method to use, but since it's vacations and we didn't have it in class yet we are not sure how to do it. Is there any method to help us out? If yes, how do you use it..? If you need any more information about the game or the enemies I'll be happy to reply! Thank you in advance, your SERGEANT JACKSON!
Super_Hippo Super_Hippo

2015/4/9

#
It could be done like this:
//move desired distance
if (isTouching(ClassName.class))
{
    //move back
}
sergeantjackson sergeantjackson

2015/4/9

#
Okay, thank you for the fast answer, I'll try it out! :)
You need to login to post a reply.