I'm trying to create a simple bowling ball animation. I would like the finger holes in the ball to turn about the center of the ball for the effect of rolling. I've casted my object to Graphics2D and used rotate
, but I don't think I'm utilizing it correctly.
public void move( )
{
setX( getX( ) + speed);
}
public void draw( Graphics g )
{
Graphics2D g2d = (Graphics2D) g;
int startY = getY( );
int startX = getX( );
//body
g.setColor( Color.BLACK );
g.fillOval( startX - 30, startY, 30, 30 );
//holes
g.setColor( Color.GRAY );
g2d.rotate(Math.toRadians(2));
g.fillOval( startX - 14, startY + 2, 6, 6 );
g.fillOval( startX - 8, startY + 10, 6, 6 );
g.fillOval( startX - 16, startY + 9, 6, 6 );
}
This is part of a larger program that moves and then draws the image incrementally. I can post more code if needed. Here's what my attempt looks like: bowling balls Thank you