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

What is happening right now?

dbutts1@stumail.com

Greenfoot 6.34 Bubbles size and direction

By dbutts1@stumail.com, with no replies.
I am trying to just put 18 bubbles of size 190 decreasing by 10 in the center of the world. They are supposed to have the direction changed by +20 degrees. I have used a while loop that looks like while ( i < bubbles.lenght) and while (i <=18) as starting points and I run into the same problem. I think I am some how getting an infinite loop, and that is why I get the following message. I get the" Exception in thread"AWT-EventQue-0" java.lang.OutOfMemoryError:Java heap space" message I also want to know why inside the loop for the addObjects I am prompted to use semicolons between parameters instead of commas. I do not get any compiling errors with the following code, but I get the message The world can't be completed. One of the classes may have an error, check them to initialize the scenario. Part of my problem may be my understanding of the vocabulary as I am very new to this. I usually use the getWidth()/2, getHetght()/2 to place objects in the center of the world but am getting the not a statement when I put in the /2 part. Here is my code form the Subclass of world. import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * A bit of empty space for bubbles to float in. * * @author Michael K├Âlling * @version 1.0 */ public class Space extends World { /** * Create Space. Make it black. */ public Space() { super(900, 600, 1); getBackground().setColor(Color.BLACK); getBackground().fill(); setup(); } private void setup() { Bubble bubble = new Bubble; int i = 0; int size = 190; int direction = 0; while( i <+18) { bubble = new Bubble(); addObject(new Bubble()+size(190)-10);direction(0+20);getWidth(); getHeight(); i=i+1; } } } I would appreciate any help anyone can give.
danpost

reply to Bubbles with a for loop

By danpost - about 1 hour ago
The class is named 'Bubble' -- not 'bubble'. You create an object from a class using the class name. So, it is not 'new bubble()', but 'new Bubble()' which you should be using.