So I am currently working on a game for a school project and in order to not have to create a new actor for every level I've decided to let the Actor count the levels, then adapt to it. But the Variable doesnt seem to be changable and I do not know why, can someone help me?
This is the important part of the code (I've tried with two levels firstly):
public void act()
{
controlls();
checkFalling();
checklevel();
getWorld().showText(""+a, 10, 10);
}
public void checklevel()
{
if (a == 1)
{
if (getY()>700 )
{
Greenfoot.setWorld(new Level1());
}
if (getX()==1650 && getY()<520 && getY()>480)
{
Greenfoot.setWorld(new Level2());
a = a + 1; //I already tried a+=1; and a++;
}
}
if (a == 2)
{
if (getY()>700 )
{
Greenfoot.setWorld(new Level2());
}
if (getX()==850 && getY()<200 && getY()>100)
{
Greenfoot.setWorld(new Level2());
a = a + 1;
}
}
}
