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

2017/5/2

Help With Bubble Tutorial?

charr103 charr103

2017/5/2

#
I am having trouble figuring out the end of the Bubble Tutorial I am supposed to do. The directions for it are: Create a new private method called setup(). Construct a while loop that will create 18 bubbles. The bubbles are all placed in the center of the world, and have sizes starting from 190, decreasing by 10. The last bubble has size 10. Make sure to create the largest first and the smallest last, so that you have bubbles of sizes 190, 180, 170, etc., all lying on top of each other. Set the initial direction as follows: the first bubble has direction 0, the next 20, the next 40, etc. That is, the direction between each two bubbles increases by 20. The code I have for it so far is: private void setup() { int i=0; while (i<18) { addObject(new Bubble(), 450, 300); i++; } }
Super_Hippo Super_Hippo

2017/5/2

#
Create the Bubble before adding it to the world.
1
2
Bubble bubble = new Bubble();
addObject(bubble, getWidth()/2, getHeight()/2);
Now, you have a reference to the bubble and can change the size and rotation.
charr103 charr103

2017/5/3

#
Okay, so I have private void setup() { int i=0; while (i<18) { int i= 0; while (i<18) { Bubble bubble = new Bubble(); addObject(bubble, getWidth()/2, getHeight()/2); i++; } }
You need to login to post a reply.