Win a copy of Android Programming: The Big Nerd Ranch Guide this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Circular motion applet  RSS feed

 
richard dela cruz
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can anyone tell me an easy way to make a single dot move in circular motion? so far... i've only done these...
 
Jelle Klap
Bartender
Posts: 1952
7
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Think about how you would normally find the X and Y coördinates of a point on the unit circle.
Then think about how you could use that same logic to implement a dot that moves in a circular motion.
 
Darryl Burke
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't use Thread#sleep(...) in a painting method override or indeed in any code that runs on the EDT.

Use a javax.swing.Timer for animation. Change the coordinates and call repaint().
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!