I want to make it so that when the projectile hits the zombie they both disappear, however only the zombie disappears. How can I fix it.
Zombie:Projectile:
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class green here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Green extends Actor
{
/**
* Act - do whatever the green wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
if(isTouching(projectile_1.class)){
projectile_1 projectile= new projectile_1();
getWorld().removeObject(projectile);
getWorld().removeObject(this);
}
}
}
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class projectile_1 here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class projectile_1 extends Actor
{
/**
* Act - do whatever the projectile_1 wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
World world= getWorld();
public void act()
{
move(2);
contact();
if (isAtEdge()){
getWorld().removeObject(this);
}
}
private void contact(){
}
}
