i have a tank canon "canon.png" and i want to rotate it from the edge not from middle
and i still confused about this code :'(
where to place it? on my canon?
Thanks for helping :')
public void act()
{
// Add your action code here.
canonMove();
GreenfootImage canon = getImage();
GreenfootImage image = new GreenfootImage(2*canon.getWidth(), canon.getHeight()); //no error on compile, but it's eror on this lineon run
image.drawImage(canon, 210,360);
setImage(image);
}
private void canonMove(){
MouseInfo mouse = Greenfoot.getMouseInfo();
int rx = mouse.getX()-getX();
int ry = mouse.getY()-getY();
int angle = (int) (Math.atan2(ry,rx)*180.0/Math.PI);
setRotation(angle);
}

