my actor is controlled by the basic up, down, left, right and space buttons. When he moves left his image flips to face the left as he moves left however when he will only shoot right which poses an issue. He is only supposed to shoot left or right, never up or down.
these are my checkKeypress and shoot methods. How do I get my actor to shoot to the left?
public void checkKeypress()
{
if (Greenfoot.isKeyDown("space"))
{
setImage(aubieShoot);
shoot();
}
if(!Greenfoot.isKeyDown("space") && !Greenfoot.isKeyDown("left"))
{
setImage(aubieRight);
}
if (Greenfoot.isKeyDown("space") && Greenfoot.isKeyDown("left"))
{
setImage(aubieShootLeft);
moveLeft();
shoot();
}
if (!Greenfoot.isKeyDown("space") && Greenfoot.isKeyDown("left"))
{
setImage(aubieLeft);
moveLeft();
}
if (Greenfoot.isKeyDown("right"))
{
moveRight();
}
if (Greenfoot.isKeyDown("up"))
{
moveUp();
}
if (Greenfoot.isKeyDown("down"))
{
moveDown();
}
shotsFired += 1;
}
public void shoot()
{
if (shotsFired >= 8)
{
Bullets bullets = new Bullets();
getWorld().addObject(bullets, getX() + getImage().getWidth(), getY());
shotsFired = 0;
}
}