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

2018/5/5

Touching image then dying

SotoVanessa_0022 SotoVanessa_0022

2018/5/5

#
I have a class that changes image. The class is the turtle. So i want myy frog to touch one of the images and die. How do i do that?
danpost danpost

2018/5/5

#
In Frog class, you would need something like this:
Turtle turtle = (Turtle) getOneIntersectingObject(Turtle.class);
if (turtle != null && turtle.hasBadImage()) getWorld().removeObject(this);
where the Turtle class has a boolean method called hasBadImage which returns true when that particular image is showing.
You need to login to post a reply.