Cards (5)

  • How do you make characters move with keys?
    if (Greenfoot.isKeyDown("direction"))
    {
    setRotation(angle);
    move(1);
    }
  • How do you make characters move randomly?
    {
    move(1);
    setRotation(Greenfoot.getRandomNumber(360));
    }
  • How do you remove an object after a collision?
    if (isTouching(Object.class))
    {
    removeTouching(Object.class);
    }
  • How do you get a sound to play?
    Greenfoot.playSound("Name.wav");
  • What is the counter code?
    Counter counter = (Counter)getWorld().getObjects(Counter.class).get(0);
    counter.add(No_of_points);