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

2012/6/10

Actors death

1
2
Girl2012 Girl2012

2012/6/18

#
and this all things I have to put into the editor of the enemy, should I?
danpost danpost

2012/6/18

#
In Bear class: - eat(Class cls) - see(Class cls) - <possibly> alterImage(String img)
Girl2012 Girl2012

2012/6/18

#
it isn't possible :( there are many erorrs
Girl2012 Girl2012

2012/6/18

#
why it doesn'twork? -.- where I have to put this things that you wrote and how ? :(
danpost danpost

2012/6/18

#
Put in the Bear class the following methods;
private boolean canSee(Class cls)
{
    return getOneIntersectingObject(cls) != null;
}

private void eat(Class cls)
{
    getWorld().removeObject(getOneIntersectingObject(cls));
}
Then, in your Bear class, in the act() method, put
if (canSee(Sheep.class)) eat(Sheep.class);
You need to login to post a reply.
1
2