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

2015/11/26

why this not work............):<

spy9144 spy9144

2015/11/26

#
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class Lander here. * * @author (spy9144) * @version (a version number or a date) */ public class Lander extends Actor { /** * Act - do whatever the ladybug wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public void act() { // Add your action code here. if (Greenfoot.isKeyDown("left")) { turn(-10); // turn left } if (Greenfoot.isKeyDown("right")) { turn(+10); // turn right } move(2); // our new behavior code is going here // make the LadyBug eat any Leaf on this square Actor leaf = getOneObjectAtOffset(0,0,Leaf.class); if (leaf != null) { World w = getWorld(); w.removeObject (apple); } } }
danpost danpost

2015/11/26

#
I see two problems with the code given. The first is that the last comment line appears to have a line of code at the end of it. The other is that the last line refers to 'apple' which does not appear to be declared anywhere (I think you may have wanted 'leaf' there).
You need to login to post a reply.