In my platform game, I added a power up that allows you to use projectiles using the letter j. Here is the code I have used:
I am trying to make the projectile fire in the direction that the character is facing. Is there anyway to do that? Thanks for reading!
public void firePower()
{
if (getOneIntersectingObject(FireFlower.class) != null && songDuration <= 0)
{
getWorld().removeObject(getOneIntersectingObject(FireFlower.class));
fireDuration = 600;
}
}
public void fireProjectile()
{
if (Greenfoot.isKeyDown("j") && shotDelay <= 0 && fireDuration > 0 && facingLeft == false)
{
getWorld().addObject(new Shot(), getX(), getY());
shotDelay = 75;
Greenfoot.playSound("FireShot.wav");
} else if (Greenfoot.isKeyDown("j") && shotDelay <= 0 && fireDuration > 0 && facingLeft == true) {
getWorld().addObject(new Shot(), getX(), getY());
shotDelay = 75;
Greenfoot.playSound("FireShot.wav");
}


