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

2021/6/8

How to make a object do something when touching an other object?

Ineedhelpthx Ineedhelpthx

2021/6/8

#
Hello, quick question: How can I make something happen in Greenfoot when objects collide? Is there something similar to isAtEdge or something like that? I'm not very experienced in programming haha
Ineedhelpthx Ineedhelpthx

2021/6/8

#
Okay Nobody answered but I figured it out. In case anybody wants to know, I used isTouching
RcCookie RcCookie

2021/6/8

#
You can get an intersecting actor using
SomeClass intersecting = getOneIntersectingObject(SomeClass.class);
If no objects of that type intersect this will return null. To get all intersecting objects of a class, you can use
List<SomeClass> intersecting = getIntersectingObjects(SomeClass.class);
Finally, if you just want to know whether this actor is touching any other actor of a given class, you can use
boolean intersects = isTouching(SomeClass.class);
Ineedhelpthx Ineedhelpthx

2021/6/8

#
thanks for the work man
You need to login to post a reply.