I don't know the correct coding to be able to click in the world and add a new object. Can someone help?


import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) import java.awt.Color; /** * Space. The final frontier. * * @author Michael Kšlling * @version 1.1 */ public class Space extends World { private String[] soundFiles = { "bass_guitar1","bass_guitar2","bass_guitar3", "bass_guitar4", "bass_guitar5" }; /** * Constructor for objects of class Space. * */ public Space() { super(960, 620, 1); createObstacles(); randomBodies(5); } /** * Create a row of abstacles across the middle of our world. */ public void createObstacles() { int i = 0; while (i < soundFiles.length) { addObject (new Obstacle (soundFiles[i] + ".wav"), 80 + i*200, i*100+100); i++; } addObject (new Blinker(),Greenfoot.getRandomNumber(940), Greenfoot.getRandomNumber(620)); } /** * Create a given number of bodies in the universe. Each body has a random initial state (size, * mass, direction, speed, color, location). */ public void randomBodies(int number) { while (number > 0) { int size = 20 + Greenfoot.getRandomNumber(30); double mass = size * 7.0; int direction = Greenfoot.getRandomNumber(360); double speed = Greenfoot.getRandomNumber(150) / 100.0; int x = Greenfoot.getRandomNumber(getWidth()); int y = Greenfoot.getRandomNumber(getHeight()); int r = Greenfoot.getRandomNumber(255); int g = Greenfoot.getRandomNumber(255); int b = Greenfoot.getRandomNumber(255); addObject (new Body (size, mass, new Vector(direction, speed), new Color(r, g, b)), x, y); number--; } } }