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

2021/3/18

My scenario is not working when I upload it to greenfoot.

Ned Ned

2021/3/18

#
At first when I uploaded it there was an error, which I fixed by removing the function to save the current level to a file. Now when I open the page it goes blank after it initializes. It works fine in the greenfoot software. Here is the scenario: Scenario
danpost danpost

2021/3/18

#
Ned wrote...
At first when I uploaded it there was an error, which I fixed by removing the function to save the current level to a file. Now when I open the page it goes blank after it initializes. It works fine in the greenfoot software. Here is the scenario: Scenario
Cannot help without seeing codes. Either re-upload (update) the scenario with the Publish source code box checked or supply codes here.
Ned Ned

2021/3/20

#
I re-uploaded it with Publish Source Code.
danpost danpost

2021/3/20

#
Ned wrote...
I re-uploaded it with Publish Source Code.
In your default world constructor, change "super(1, 1, 1);" to "super(600, 700, 1);". Also (side note), you use of while to wait for key is unwieldy. Better is to use if on a condition (like, "if scroll exists and 'space' is pressed" or "if no scroll and no fireball and 'space' is pressed".
Ned Ned

2021/3/20

#
Thanks!
danpost danpost

2021/3/20

#
Ned wrote...
Thanks!
To only have response on only one of key up or key down:
// add field
private boolean spaceDown;

// for detection
if (getWorld().getObjects(Fireball.class).isEmpty()) // level not active
{
    if (spaceDown != Greenfoot.isKeyDown("space")) // change in state of "space" key
    {
        spaceDown  = ! spaceDown;
        if (spaceDown == false) // on new state  (change false to true for response on key press instead of release)
        {
            if (getWorld().getObjects(Scroll.class).isEmpty()) // scrolling done
            {
                // add fire ball
            }
            else // scrolling not done
            {
                // next scroll (or removal of final scroll)
            }
        }
    }
}
Ned Ned

2021/3/20

#
Thanks again!
You need to login to post a reply.