Hey guys, got a problem with this code.
Its about the checkposition1() method. It is simply not working, I dont even get an error. No idea whats the problem. I already tried the code in a different greenfoot project, still no response.
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.util.List;
import java.awt.Color;
import java.awt.Font;
/**
* Write a description of class andreas here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class andreas extends Actor
{
/**
* Act - do whatever the andreas wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
if(this != null && this.getWorld() != null)
{
setLocation(getX()-3,getY());
checkposition1();
checkTouching();
}
}
public void checkTouching()
{
if(this != null && this.getWorld() != null)
{
if(isTouching(explosion.class))
{
removeTouching(explosion.class);
MyWorld myWorld = (MyWorld)getWorld();
myWorld.addScore(2);
getWorld().addObject(new missile(), 35, 375);
Greenfoot.playSound("sounds/andreas.mp3");
getWorld().removeObject(this);
return;
}
if(isTouching(andreas.class))
{
getWorld().addObject(new andreas(),1550, Greenfoot.getRandomNumber(900));
getWorld().removeObject(this);
return;
}
}
}
public void checkposition1()
{
if(getX() == 10)
{
getWorld().addObject(new TextField(1600, 200, Color.white, Color.black ," Click Reset for"), 800, 200);
getWorld().addObject(new TextField(1600, 200, Color.white, Color.black ," "), 800, 0);
getWorld().addObject(new TextField(1600, 200, Color.black, Color.blue ," GAME OVER"), 800, 400);
getWorld().addObject(new TextField(1600, 200, Color.white, Color.black ," another shot."), 800, 600);
getWorld().addObject(new TextField(1600, 200, Color.white, Color.black ," "), 800, 800);
Greenfoot.stop();
}
}
}
