I have a Maze game where there are coins that you can collect, I would like the score to continue across 3 Levels.


1 2 3 4 5 6 7 8 9 10 11 12 13 | //in class A //constructor without parameter public A() { //… } //constructor with an int as parameter public A( int a) { //… } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | 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) } } |