So I have this code and no errors pop up, but nothing happens when its supposed to reset the level when the fall is completed. I think it might be the way I ordered things, but then I tried to reorder things and messed it up even more so I put it back to normal.
Here's the code
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class Fall here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Fall extends Effects
{
private GreenfootImage EggFall = new GreenfootImage ("FallingEgg.png");
private WorldLoader world;
float ys = -4;
float y =0;
public void addedToWorld(World world) {
this.world = (WorldLoader) world;
y = getY();
}
public Fall ()
{
EggFall.scale(25,50);
setImage(EggFall);
}
/**
* Act - do whatever the Fall wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
y += ys;
fallPhysics();
setLocation(getX(),(int) y);
retryLevel();
}
public void fallPhysics()
{
if (ys< 6)
{
ys+=0.3;
}
if(y<0)
{
y = 0;
ys = 1;
}
}
public void retryLevel()
{
if(y>500)
{
world.restartLevel();
}
}
}
