DucCuong
DucCuong

Reputation: 648

Rotational Circle in JavaFX

I'm creating an application which consists a simulation for uniformly rotational circle with decreasing acceleration. But it does not have to be exactly like in Physics. And I'm using JavaFX. I'm using Animation and Timeline in JavaFX. However, as far as I know, they just create animation in a fixed duration. However, my application requires that the circle decreases its speed to zero and then stops.

Any idea or clue on how should I do that. I really appreaciate your help!

Edit: If I need to rotate the circle according to the initial mouse speed. How shoudl I do that?

Upvotes: 0

Views: 458

Answers (2)

James_D
James_D

Reputation: 209319

Use a RotateTransition and specify a custom interpolator.

Upvotes: 1

TheHuffen
TheHuffen

Reputation: 1

I don't use JavaFX, but there should be something like a 'rotate(degrees)' method somewhere. If so, just rotate it a little less every frame until it stops. Here are some psuedo-code:

    float degrees = 60;
    JavaFXThing thing;

    //Every frame
    while (true){
        thing.rotate(degrees);
        thing.draw();
        degrees -= 0.05;
    }

Hope it helped!

Upvotes: 0

Related Questions