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

2013/5/12

getOneTouchingObject();

Kartoffelbrot Kartoffelbrot

2013/5/12

#
I need a method that works like the getOneIntersectingObject()-method, but not if the images intersect, rather, when they are touching each other. Thats for my walls.
GreenGoo GreenGoo

2013/5/12

#
A new method was added in Greenfoot 2.3.0, isTouching(). I've never used it but it might be what you are looking for.
Kartoffelbrot Kartoffelbrot

2013/5/12

#
Thanks.
danpost danpost

2013/5/12

#
There is no method to do what you want (you have to program it yourself). The new 'isTouching' method is basically a shortcut for '!getIntersectingObjects(class).isEmpty()' or for 'getOneIntersectingObject(class) != null'. Usually, what you would do is go ahead and move the actor, then check for intersection. If intersection occurs, move the actor back. This is done all within the same act cycle; so, the actor appears to just stop at the wall.
Kartoffelbrot Kartoffelbrot

2013/5/13

#
Great idea! Thank you!
You need to login to post a reply.