I have a button that when I press it and go to my main world it should add it to the world but it doesn't work for some reason and I can't figure it out please help. Here is my Ak47 class
and here is the problematic part of my Human class
public class Ak47 extends Guns
{
Human hooman;
private static GreenfootImage rightImage= new GreenfootImage("Ak47Right.png");
private static GreenfootImage leftImage= new GreenfootImage("Ak47Left.png");
public Ak47()
{
Human.fireRate = 17;
Human.clipSize = 10;
Human.clip = 10;
Human.reloadTime = 200;
if (hooman.direction == "a" && hooman.life > 0)
{
setLocation (hooman.getX() -10, hooman.getY() -4);
}
else if (hooman.direction == "d" && hooman.life > 0)
{
setLocation(hooman.getX() +10, hooman.getY() -4);
}
}
public void act()
{
turn();
move();
}
public void turn()
{
if (hooman.direction == "a")
{
setImage(leftImage);
}
else if(hooman.direction == "d")
{
setImage(rightImage);
}
}
public void move()
{
Human hooman = (Human) getWorld().getObjects(Human.class).get(0);
if (hooman.direction == "a" && hooman.life > 0)
{
setLocation(hooman.getX() -10, hooman.getY() -4);
}
else if (hooman.direction == "d" && hooman.life > 0)
{
setLocation(hooman.getX() +10, hooman.getY() -4);
}
}
}public void checkForGun()
// This is where the guns are spawned in
{
if(boughtAk == true && spawnedAk == false)
{
getWorld().addObject (new Ak47(), getX(), getY());
spawnedAk = true;
}
if(boughtDeagle == true && spawnedDeagle == false)
{
getWorld().addObject(new DesertEagle(), getX(), getY());
spawnedDeagle = true;
}
if(boughtDeagle == true && boughtAk == true)
{
getWorld().removeObject(deserteagle);
}
}