It is necessary to simulate the movement of the planets in the solar system. Planets painted outline. You need to ask them to move. So far there are 3 planets. I want to ask them to move Timer'om. I can not figure out how to make the rotation of the planet in a circle and do not understand exactly where to call the schedule. in programming novice
public class SolarSystem extends View { public SolarSystem(Context context) { super(context); } Paint sun = new Paint(); Paint mercury = new Paint(); Paint venus = new Paint(); Paint ears = new Paint(); Paint circles = new Paint(); boolean stars = true; int X_Mercury = 700; int Y_Mercury = 750; int R_Mercury = 30; int A_Mercury = 1; @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); canvas.drawColor(Color.BLACK); if (stars) { for (int i = 0; i < 250; i++) { circles.setColor(Color.rgb(250, 250, 250)); canvas.drawCircle((float) (Math.random()*1080), (float) (Math.random()*1920), 1, circles); } for (int i = 0; i < 40; i++) { circles.setColor(Color.rgb(250, 250, 250)); canvas.drawCircle((float) (Math.random()*1080), (float) (Math.random()*1920), 3, circles); } for (int i = 0; i < 20; i++) { circles.setColor(Color.rgb(250, 250, 250)); canvas.drawCircle((float) (Math.random()*1080), (float) (Math.random()*1920), 4, circles); } stars = false; } circles.setColor(Color.argb(50, 250, 250, 250)); circles.setStyle(Paint.Style.STROKE); canvas.drawCircle(550, 800, 160, circles); canvas.drawCircle(550, 800, 275, circles); canvas.drawCircle(550, 800, 425, circles); sun.setColor(Color.YELLOW); canvas.drawCircle(550, 800, 100, sun); mercury.setColor(Color.rgb(184, 134, 11)); canvas.drawCircle(X_Mercury, Y_Mercury, R_Mercury, mercury); venus.setColor(Color.rgb(160, 82, 45)); canvas.drawCircle(650, 550, 45, venus); ears.setColor(Color.rgb(0, 0, 128)); canvas.drawCircle(250, 500, 60, ears); start(); } public void movingMercury(){ X_Mercury = (int) (700 + 30 * Math.cos(A_Mercury++)); //cos (t*a) Y_Mercury = (int) (750 + 30 * Math.sin(A_Mercury++)); } Timer tMercury = new Timer(); TimerTask ttMercury = new TimerTask() { @Override public void run() { movingMercury(); invalidate(); } }; public void start() { tMercury.schedule(ttMercury, 100); } }