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

2017/6/22

So I am trying to make it so when the fireball class intersects with the spider class once, the spider class dies

Sirpancakeking Sirpancakeking

2017/6/22

#
So not just when the images of the fireball and spider are intersecting but if they are/have intersected then the spider dies. Also if a spider touches the main character then how could i make it so a boolean variable is true so I can switch worlds to a death screen world.
Yehuda Yehuda

2017/6/22

#
What's the difference between: "when the images of the fireball and spider are intersecting" and "they are/have intersected"? In the spider class you can put the following code at the end of the Spider's act method.
if (isTouching(Fireball.class)) { //if spider touching fireball
    removeTouching(Fireball.class); //remove fireball
    getWorld().removeObject(this); //remove spider
}
Sirpancakeking Sirpancakeking

2017/6/22

#
ok thank you, so do you know of any code that would make it so when a spider touches the main class then the world switches to a deathscreen world?
Yehuda Yehuda

2017/6/22

#
In class Main you can put the following in the act method.
if (isTouching(Spider.class)) {
    Greenfoot.setWorld(new DeathScreen());
}
You need to login to post a reply.