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

2013/9/12

Detecting an Image

Y3llowMustang Y3llowMustang

2013/9/12

#
Hello everyone, I'd like to detect the image of another Actor when my object collides with thus Actor. How would I go about doing this? Thank you.
danpost danpost

2013/9/12

#
Review the methods in the Actor class API for what might help.
Y3llowMustang Y3llowMustang

2013/9/13

#
I've found getImage() but I haven't found any related posts to it. How would I use?
Gevater_Tod4711 Gevater_Tod4711

2013/9/13

#
You can use the methods getIntersectingObjects or getOneIntersectingObject from the greenfoot API to detect whether your actor touches another actor. The method getIntersectingObjects will return a list of objects and getOneIntersectingObject will only return one object. You can use this methods e.g. like this:
if (!getIntersectingObjects(Actor.class).isEmpty()) {
    //your object is touching another actor;
}

if (getOneInteresectingObject(Actor.class) != null) {
    //your object is touching another actor;
}
You need to login to post a reply.