• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Javafx orbit sphere around other sphere like solar system

 
kamil czarny
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello. I'm new here but i very need your help.
I would like to do something like solar system. I have 3 sphere Sun, Earth,Moon
In my code Earth is rotating properly around the Sun, but But the Moon does not want to properly rotate around earth. I dont know why. Can you help me?
 
Knute Snortum
Bartender
Pie
Posts: 2882
62
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch!

This looks like it will get better responses in the JavaFX forum, so I moved it there.
 
Mark Onelppa
Greenhorn
Posts: 4
IntelliJ IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, I also am new here and new to JavaFX and I happened upon this post when looking for what JavaFX can do and it caught my attention.

I am by no means an expert, I started looking in to JavaFX a little over a week ago and have no prior experience in JavaFX animations.

With that said, with a little testing it seems that you are creating a path for a sphere to follow and then moving that path around, problem seems to be that once an animation has started, it's path cannot be altered, you would need to stop() and play() it after the path has changed and would not work since the path moves around constantly.

Backed with this information I thought that the paths and sphere do move along with the pane they are in.
So I added a new Anchorpane that is bound to the earth spheres location and added the moon into that instead and the result seems to be what you wanted.
I also commented some code that I deemed unnecessary since the path cannot change so there is no need to move it.


There may be alternative methods but this atleast works, hope it helps.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic