hi everyone,
i need your help again. I want an actor to die when a certain picture of another actor touches him.
thanking you in anticipation :)
if(getOneIntersectingObject(Enemy.class) != null)
{
if(){
getWorld().removeObject(this);
return;
}
}if(getOneIntersectingObject(Enemy.class) != null)
{
Actor enemy = getOneIntersectingObject(Enemy.class);
if(enemy.getImage() == killer){
getWorld().removeObject(this);
return;
}
} if (getOneIntersectingObject(Enemy.class) != null)
{
Enemy enemy = (Enemy) getOneIntersectingObject(Enemy.class);
if ("killer.png".equals(enemy.currentImage)) getWorld().removeObject(this);
}public class Bear extends Actor
{
String image1 = "bear.png";
String image2 = "bear2.png";
String currentImage = image1;private void eat(Class cls)
{
Actor actor = getOneIntersectingObject(cls);
getWorld().removeObject(actor);
currentImage = image2;
setImage(currentImage);
}if (see(Sheep.class)) eat(Sheep.class);
private boolean see(Class cls)
{
return getOneIntersectingObject(cls) != null;
}if (see(Sheep.class))
{
eat(Sheep.class);
alterImage(image2);
}private void alterImage(String img)
{
currentImage = img;
setImage(currentImage);
}