Hi guys.
I have been out of the loop for many months I hope to learn Greenfoot again.
I created a World with a single object names karate1 in it.
Then under the object class, I wrote the following code:
So far so good. When I run the code and press the key "e" down the object is removed from the world.
Then I created a second object Karate2 and wrote the following code:
It doesn't reposnd I was expecting the object Karate2 be added to the world.
Is there anyone that could give some directions?
public class Dojo extends World{
public Dojo() {
super(550, 400, 1);
prepare();
}
public void prepare() {
Karate1 k1 = new Karate1();
addObject(k1, 225,250);
}
}public class Karate1 extends Actor {
public void act() {
if (Greenfoot.isKeyDown("e")) {
getWorld().removeObject(this);
}
}
}
public class Karate2 extends Actor{
public void act(){
if (Greenfoot.isKeyDown("c")){
Karate2 k2 = new Karate2();
getWorld().addObject(k2,225, 250);
}
}
}

