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

2018/4/8

Intersecting Actors

Lavenger Lavenger

2018/4/8

#
how do I check if an actor is intersecting with another actor?
danpost danpost

2018/4/8

#
Lavenger wrote...
how do I check if an actor is intersecting with another actor?
There are multiple collision methods provided by the Actor class. One of them will probably suit your needs.
Lavenger Lavenger

2018/4/8

#
why is this code wrong?:
if((this.getOneIntersectingObject(MiniKirie.class)) == true)
        {
                getWorld().removeObjects(getObjects(Actor.class));
        }
== true and getObjects are underlined and states "Incomparable types: greenfoot.Actor and Boolean" and "cannot find symbol - method getObjects(java.lang.Class<greenfoot.Actor>)" respectively
danpost danpost

2018/4/8

#
Line 1 should be '!= null' -- not '== true'. Although, more simply would be:
if (isTouching(MiniKirie.class))
Line 3 should be
getWorld().removeObjects(getWorld().getObjects(Actor.class));
Lavenger Lavenger

2018/4/8

#
danpost wrote...
Line 1 should be '!= null' -- not '== true'. Although, more simply would be:
if (isTouching(MiniKirie.class))
Line 3 should be
getWorld().removeObjects(getWorld().getObjects(Actor.class));
ahh okay, thanks ^^
You need to login to post a reply.