Ok, I have only one problem now, I made a game over screen just like the title screen, but if I use this code it won't work, do I make another game over thing but this time in class or is there a way to use the one thaf I made in th world.
if (getObjects(Block.class).isEmpty()) wonGame(); if (Greenfoot.mouseClicked(this)) lostGame();
public void act() {
this.setLocation (getX(), getY() +1);
if (getY()>getWorld().getHeight()+10)
{
this.getWorld().removeObject(this);
}
if (Greenfoot.mousePressed(this))
{
Greenfoot.playSound(soundfile);
turnWhite();
}
if (Greenfoot.mouseClicked(this)) {
//code for pressed tile
}
}
if(Greenfoot.mouseClicked(null)){
addScore();public class Tile extends Actor {
public void act() {
if (Greenfoot.mouseClicked(this)) {
((Counter)getWorld().getObjects(Counter.class).get(0)).addScore();
}
}
}
public class Counter_w5 extends Actor
{
int score = 0;
int max = 20;
/**
* Act - do whatever the Counter_w5 wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
setImage(new GreenfootImage("Score : " + score, 24, Color.BLACK, Color.WHITE));
if (Greenfoot.mouseClicked(this))
{
((Counter_w5)getWorld().getObjects(Counter_w5.class).get(0)).addScore();
}
}