• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to move this object around?  RSS feed

 
annie roberts
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried to add the x and y coordinate in different places in the g.drawLine and it doesn't move. I have the correct picture but I need it to move.

 
Campbell Ritchie
Sheriff
Posts: 53774
128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where are you calling drawPict(g) from? Is it in the paintComponent method? Have you called super.paintComponent(g); as the first statement in paintComponent?
[ April 23, 2008: Message edited by: Campbell Ritchie ]
 
Campbell Ritchie
Sheriff
Posts: 53774
128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
. . . and you are always setting the spokes to the same location in drawPict(). You don't change the angles they appear at. Change Math.PI*2*i/numSpokes to Math.PI*2*i/numSpokes + offset. Change offset slightly every time you draw the picture. Put a delay with Thread.sleep() between successive calls to drawPict.

Beware: Thread.sleep() declares a checked InterruptedException which you have to deal with.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!