0

私は移行中の私の落下円が現在どの位置にあるかを調べようとします。何が必要ですか?各秒を設定するタイマー。円の位置?または、実際の位置の値を取得する方法の提案。

このコードは、私のhitOuterCirlceメソッドの一部と、同じgetCenterX(円の値)を示しています。

 // (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());

どうすればこれを修正できますか?

グリーツ

4

1 に答える 1

1

circle の centerX/Y プロパティにバインドするだけです

サンプルコード:

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);
        }
    });
于 2013-02-08T20:45:07.267 に答える