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

2014/4/2

Making an actor eat

Greenfootnoob Greenfootnoob

2014/4/2

#
G'day, I'm having trouble with making my Actor eat an objet (Penguin eating chips). heres my code.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
public void act()
   {
       checkKeys();
       checkFall();
       jump();
       Eat();
   }
 
   public void Eat()
   {
       if(canSee(Chips.class));
       {
           eat(Chips.class);
       }
   }
It says that it cannot find the symbol.Can anyone help?
davmac davmac

2014/4/2

#
It cannot find which symbol?
danpost danpost

2014/4/2

#
If your Penguin class extends Actor, then you probably do not have a 'canSee' or an 'eat' method available (unless you added them yourself within the class). Those methods are part of the Animal class which you can import using the menubar 'Edit>Import class...'. You can then copy/paste the methods over into the Penguin class or have the Penguin class extend the Animal class.
handfive handfive

2016/8/10

#
I am trying to get the spider to eat the man, what should i do?
danpost danpost

2016/8/10

#
handfive wrote...
I am trying to get the spider to eat the man, what should i do?
You should start a new discussion thread and not revive old ones. Try:
1
2
3
4
if (isTouching(Man.class))
{
    removeTouching(Man.class);
}
handfive handfive

2016/8/12

#
Thank you very much!
You need to login to post a reply.