0

I am trying to decide if I should use timeline or transition to animate a vehicle

I am working on a project to create a traffic simulator. Basically I have a base lane (circle) and I can add more up to a limit of 5. I can place a vehicle (rectangle object) going around the lane, making it move indefinitely. To do this I have been using path transition, I am now struggling to use path transitions to make the vehicle go around obstacles by changing lane, so use a transition to move to the side and then to pick up the circle of the new lane and move. I have been reading other threads and I am not sure if using a path transition is the best option. Has someone had a similar experience and can offer advice?

chaimite
  • 114
  • 13
  • 1
    I would use `Timeline` or `AnimationTimer`. – SedJ601 Aug 08 '19 at 21:44
  • 1
    https://stackoverflow.com/questions/29057870/in-javafx-how-do-i-move-a-sprite-across-the-screen – SedJ601 Aug 08 '19 at 21:46
  • 2
    If you can/want to determine the whole path before starting the animation, `PathTransition` may work (using a `Path` shape), but if you want a dynamically changing road (e.g. including multiple cars or pedestrians crossing the street you may not be able to simulate the whole animation beforehand... Simply choose the tool that makes your life easier. To me it sounds like `Timeline` or `AnimationTimer` would be better on the long term. – fabian Aug 09 '19 at 09:35
  • 2
    You guys make sense, I will go for the animation timer, since it seems to have more control. I will only have vehicles, and I have to detect collisions before they happen. So if the vehicle in front stops, the vehicle will have to break and stop or check the lanes on the side and change lane, I am not sure how to handle that, but I guess when the time comes I will have to figure it out. Thanks for you feedback. – chaimite Aug 09 '19 at 11:20

0 Answers0