I need help accessing one class's rotation from another class. For example, I need to have a bullet class know a turret's rotation so it fires the right way.
public static int rotation = 0;
public void act() {
rotation = getRotation();
}// in the turret class code, when triggered to fire a bullet Bullet bullet = new Bullet(); bullet.setRotation(getRotation()); addObject(bullet, getX(), getY());
if(Greenfoot.isKeyDown("space"))
{
bullet bullet = new bullet();
bullet.setRotation(getRotation());
addObject(bullet, getX(), getY());
}
} if (Greenfoot.isKeyDown("space"))
{
if(ammo > 0)
{
//the fire code
ammo = -10;
}
}
else
{
ammo = (ammo + 1);
}if (Greenfoot.isKeyDown("space"))
{
if(ammo > 0)
{
//the fire code
ammo = -10;
}
}
else
{
ammo = (ammo + 1);
}