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

2018/12/13

How to make an actor exit into another actor from certain points?

Zaki99 Zaki99

2018/12/13

#
I need help . I been trying to figure out how to make a code that can let my actor Mouse got to the actor Door when it collects 20 cherries.
danpost danpost

2018/12/13

#
Zaki99 wrote...
how to make a code that can let my actor Mouse got to the actor Door when it collects 20 cherries.
What attempt(s) have you tried? Show Mouse class act method.
Zaki99 Zaki99

2018/12/13

#
public class Mouse extends Actor { public void act() { moveAndTurn(); eat(); } public void moveAndTurn() { if(Greenfoot.isKeyDown("Up")) { move(3); } if (Greenfoot.isKeyDown("left")) { turn(-2); } if(Greenfoot.isKeyDown("right")) { turn(2); } if(Greenfoot.isKeyDown("down")) { move(-2); } } public void eat() { Actor Cherry; Cherry = getOneObjectAtOffset(0, 0, Cherry.class); if (Cherry != null) { World world; world = getWorld(); world.removeObject(Cherry); MyWorld myWorld =(MyWorld)getWorld(); Counter counter = myWorld.getCounter(); counter.bumpCount(2); } } }
Zaki99 Zaki99

2018/12/13

#
I have try doing different if and else statements with a Boolean but none of them work.
You need to login to post a reply.