I forgot to mention (I posted the other comments) that I changed the touch(Class clss) method to just be
getOneTouchedObject(clss) != null
as all the code for it instead of having all the code there twice (not exactly the same code but does the same thing).
Well, I used 'getWorld().getObjects()', because getIntersectingObjects() also iterates over all Objects in the World-class, checks whether they intersect and then returns the list. So there's no affect to the running-time. In the 'getOneTouchedObject'-method it could also save some time, if one of the first objects in the list touches it... So the 'intersect'-method don't have to be called on all actors...
A new version of this scenario was uploaded on 2017-05-09 19:48:47 UTC
Latest Greenfoot-Version...
But with using getWorld().getObjects(), I ran into problems when I tried to check if one instance of a class is touching a different instance of the same class, so I changed it (and if you leave it alone, other people can/will have the same problem).
I got the idea of changing the touch method, from the greenfoot.Actor class which did that.
"Well, I used 'getWorld().getObjects()', because getIntersectingObjects() also iterates over all Objects in the World-class, checks whether they intersect and then returns the list. So there's no affect to the running-time" - this is not correct. The collision checking in Greenfoot is sophisticated and maintains a dynamic space partition tree to make intersection checks very fast.
2017/5/3
2017/5/9
2017/5/10
2017/5/10
2017/5/10
2017/5/11
2017/7/29
2017/8/4
2020/2/5