Hi, i want to put my score actor in three modes of my game, but i can´t do that, its only work in one.
ScoreCounter.score = 0;
import greenfoot.*;
import java.util.List;
import java.awt.Color;
import java.awt.Font;
/**
* Write a description of class Pontuação here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Pontuacao extends Actor
{
private GreenfootImage imagem;
private int pontuação = 0;
private Color CorMenu;
/**
* Constructor for the score.
*
*/
public Pontuacao()
{
imagem = getImage();
imagem.clear();
imagem.scale(100,70);
escreve("0");
}
/**
* Act - do whatever the Pontuação wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
// Add your action code here.
if(getWorld()!=null)
{
escreve(""+pontuação);
}
}
/**
Método para escrever a pontuação
*/
public void escreve(String pontos)
{
imagem.clear();
imagem = this.getImage();
CorMenu = new Color(255,204,153);
imagem.setColor(CorMenu);
imagem.fill();
this.setImage(imagem);
imagem = getImage( );
Font letra = new Font("Arial", Font.BOLD,12);
imagem.setFont(letra);
imagem.setColor( Color.BLACK );
int x = 5;
int y = 20;
imagem.drawString("Score: "+pontos, x+24, y);
//imagem.drawString("Highscore: " + pontos ,x,y+20);
}
public void contaPontos()
{
pontuação++;
}
}
Pontuacao.pontuação = 0;