If you want to be able to shoot, you need two classes. The class, who is the player, and who should be shoot. The other one should be the bullet or laser or whatever you want to shoot. Then you can use this method:
The act method of the shooter/player shoul be like this:
In the act method of the bullet, you have to write only: move(10) or how fast the bullet should be.
public void shoot()
{
Projectile bullet = new Projectile();
//Projectile has to be the class, which you shoot.
//bullet is only the name for it. You can name it "Peter" too.
getWorld().addObject(bullet, getX(), getY());
//here the bullet is set into the world
bullet.setRotation(getRotation);
//here the bullet is turned into the direction you are facing to
bullet.move(getImage().getWidth()/2+bullet.getImage().getWidth()/2);
//this is optional. It makes the bullet coming out at the front of the shooter
}public void act()
{
if(Greenfoot.isKeyDown("space")) //or how the controls to shoot be like
{
shoot();
}
}

