I have a Maze game where there are coins that you can collect, I would like the score to continue across 3 Levels.
//in class A
//constructor without parameter
public A()
{
//…
}
//constructor with an int as parameter
public A(int a)
{
//…
}public class Player extends Actor
{
public int coinsCollected;
}
public void act()
{
getWorld().showText("Score: "+coinsCollected, 50, 50);//shows the score
if (isTouching(Coin.class))
{
coinsCollected = coinsCollected +1;
removeTouching(Coin.class);//removes a coin when you touch it
}
if (coinsCollected == 5)
{
getWorld().removeObjects(getWorld().getObjects(Lock.class));//removes a lock when you meet the criteria (5 coins)
}
}