I added bullet code to my character but I don't know how to make my character shoot in the direction of which my character is facing. I have tried about anything on the internet but nothing seems to work. this is my code.
public class Soldaat extends Actor { public void act() { { if (Greenfoot.isKeyDown("up")) { setLocation(getX(),getY()-3); this.setImage("characters1Up.png"); } if (Greenfoot.isKeyDown("down")) { setLocation(getX(), getY()+3); this.setImage("characters1Down.png"); } if (Greenfoot.isKeyDown("left")) { setLocation(getX()-3, getY()); this.setImage("characters1Left.png"); } if (Greenfoot.isKeyDown("right")) { setLocation(getX()+3, getY()); this.setImage("characters1Right.png"); } { checkFire(); } } } public void checkFire() { if(Greenfoot.isKeyDown("space")) { getWorld().addObject(new Bullet(), getX(), getY()); Bullet.setRotation(getRotation()); } } }