tAise
tAise

Reputation: 13

Current circle position of javafx transition

im try to find out what current position my falling circle on transition have. What do i need for it? A timer to set each sec. the position of circle? Or any suggestion how to get the real position value.

This code shows a part of my hitOuterCirlce method and even the same getCenterX - value of the circle:

 // (x-u)*(x-u) + (y-v) )*(y-v) < (r * r)
    // outer circle:
    double u = 2 * (3.141 * circle.getRadius());
    double res1 = (circle.getCenterX() - u) * (circle.getCenterX() - u);
    double v = (1.333 * 3.141) * (circle.getRadius() * circle.getRadius()) * circle.getRadius();
    double res2 = (circle.getCenterY() - v) * (circle.getCenterY() - v);
    double res3 = (circle.getRadius() * circle.getRadius());

How can i fix this?

greetz

Upvotes: 0

Views: 1203

Answers (1)

invariant
invariant

Reputation: 8900

just bind to centerX/Y property of circle

Sample Code :

DoubleProperty xValue = new SimpleDoubleProperty();
    xValue.bind(circle.centerXProperty());
    xValue.addListener(new ChangeListener() {
        @Override
        public void changed(ObservableValue arg0, Object arg1, Object arg2) {

            System.out.println(" Current center X : " + (double) arg2);
        }
    });

Upvotes: 1

Related Questions