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

2019/1/10

Compiling in Greenfoot

TNesler TNesler

2019/1/10

#
I was able to download one of the game scenarios from the Joy of Code (episode 16). I tried to run the scenario and a notice appeared saying that the code was compiled using version 2.2 and would need to be updated to version 3.0. I said yes and the code was updated without errors, however no background or actors appeared. Instead I got message saying:
The world could not be constructed. The world subclass may not have a public constructor without parameters or may not be public.
I tried to recompile the code but nothing happened. What should I do to fix this? Also, sometimes, I go into the World subclass and make changes. When I am done, the game area goes "fuzzy" and then I can't seem to get it to start without exiting and reloading the game. Is there a shortcut to this? Thanks for your help!
danpost danpost

2019/1/10

#
Please post the code currently in the World subclass.
danpost danpost

2019/1/11

#
TNesler wrote...
Also, sometimes, I go into the World subclass and make changes. When I am done, the game area goes "fuzzy" and then I can't seem to get it to start without exiting and reloading the game. Is there a shortcut to this?
You might try showing the debugger and clicking on "Terminate".
TNesler TNesler

2019/1/12

#
Here is the code for the TurtleWorld subclass.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import greenfoot.*;  // imports Actor, World, Greenfoot, GreenfootImage
 
public class TurtleWorld extends World
{
    /**
     * Create the turtle world. Our world has a size
     * of 560x460 cells, where every cell is just 1 pixel.
     */
    public TurtleWorld()
    {
        super(600, 480, 1);
 
        prepare();
    }
 
    /**
     * Prepare the world for the start of the program. That is: create the initial
     * objects and add them to the world.
     */
    private void prepare()
    {
        Turtle turtle = new Turtle();
        addObject(turtle, 171, 168);
        Lettuce lettuce = new Lettuce();
....  More lettuce objects .....
        Snake snake = new Snake();
        addObject(snake, 456, 73);
        Snake snake2 = new Snake();
        addObject(snake2, 72, 396);
        Snake snake3 = new Snake();
        addObject(snake3, 484, 296);
        Bug bug = new Bug();
        addObject(bug, 361, 159);
        Bug bug2 = new Bug();
        addObject(bug2, 222, 402);
    }
}
TNesler TNesler

2019/1/12

#
My apologies. Not sure how it happened, but I was able to recompile the Trick the Turtle example and it works now. I will look for the termination option when I encounter this problem again.
You need to login to post a reply.