I want that the "Mans.class" is in front of the "Objects.class", because ussully the "Objects.class" is before the "Mans.class"
This is my Mans code.
import greenfoot.*;
public class Mans extends Actor
{
public int ySpeed;
public int groundLevel=489;
private boolean pressed;
public void act()
{
boolean onGround = false;
ySpeed++;
setLocation(getX(), getY()+ySpeed);
// at ground level
if (getY() > groundLevel)
{
ySpeed = 0;
setLocation(getX(), groundLevel);
onGround = true;
}
// hitting box
Actor object = getOneIntersectingObject(Objects.class);
if (object != null)
{
int yDir = (int)Math.signum(ySpeed);
setLocation(getX(), object.getY()-yDir*((object.getImage().getHeight()+getImage().getHeight())/2+1));
ySpeed = 0;
if (yDir > 0) onGround = true;
}
// jumping
if (onGround && Greenfoot.isKeyDown("up")) ySpeed = -15;
// firing weapon
if (pressed == Greenfoot.isKeyDown("space"))
{
pressed = !pressed;
if (pressed) getWorld().addObject(new Weapons(), getX()+80, getY()-25);
}
//die
if (this.isAtEdge())
{
this.removeTouching(Objects.class);
this.setImage("Death_Man.png");
this.setLocation(150, 520);
Greenfoot.playSound("game-over.wav");
Greenfoot.stop();
//Here I want to put the "Mans.class" in front of the other Objects.
}
}
}