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

2014/6/30

How can you check if ANY class has touched you?

SB001 SB001

2014/6/30

#
Hey guys, I was wondering if it is possible to check if your object has hit ANY other object. This is not limiting it to one class but say if there is a car, a motorcycle, a bus, a train and about a dozen other things and you want to see if the frog has been hit by any of them with out checking each individually. By this I mean something where you could do:
if (WHAT YOU ARE TELLING ME != null) {
           getWorld().removeObject(this);
}
or something like that. Is this possible? Thanks in advance, SB001 - Samuel.T.Brown
davmac davmac

2014/6/30

#
How about 'getOneIntersectingObject(Actor.class)'.
danpost danpost

2014/6/30

#
davmac wrote...
How about 'getOneIntersectingObject(Actor.class)'.
Or, as the Actor class API documentation states:

getOneIntersectingObject

protected Actor getOneIntersectingObject(java.lang.Class cls) Return an object that intersects this object. This takes the graphical extent of objects into consideration. Parameters: cls - Class of objects to look for (passing 'null' will find all objects).
I made bold the pertinent part in the last line.
SB001 SB001

2014/7/1

#
Thanks guys, I totally forgot about passing null. I've used that. Thanks, SB001 - Samuel.T.Brown
You need to login to post a reply.