Search in sources :

Example 1 with Interpolators

use of com.almasb.fxgl.animation.Interpolators in project FXGL by AlmasB.

the class InterpolatorSample2 method initGame.

@Override
protected void initGame() {
    int i = 0;
    for (Interpolators interpolator : Interpolators.values()) {
        Text t = getUIFactory().newText(interpolator.toString() + ":");
        t.setFill(Color.BLACK);
        Pane p = new Pane(t);
        p.setTranslateY(i * 50 + 25);
        Line line = new Line(0, i * 50, getWidth(), i * 50);
        line.setStroke(Color.RED);
        getGameScene().addUINodes(p, line);
        Texture texture = DSLKt.texture("bird.png").toAnimatedTexture(2, Duration.seconds(0.5));
        Entity bird = Entities.builder().at(100, i * 50).viewFromNode(texture).buildAndAttach();
        Entities.animationBuilder().interpolator(interpolator.EASE_OUT()).duration(Duration.seconds(2)).repeatInfinitely().translate(bird).from(new Point2D(100, i * 50)).to(new Point2D(400, i * 50)).buildAndPlay();
        i++;
    }
}
Also used : Line(javafx.scene.shape.Line) Entity(com.almasb.fxgl.entity.Entity) Point2D(javafx.geometry.Point2D) Interpolators(com.almasb.fxgl.animation.Interpolators) Text(javafx.scene.text.Text) Pane(javafx.scene.layout.Pane) Texture(com.almasb.fxgl.texture.Texture)

Aggregations

Interpolators (com.almasb.fxgl.animation.Interpolators)1 Entity (com.almasb.fxgl.entity.Entity)1 Texture (com.almasb.fxgl.texture.Texture)1 Point2D (javafx.geometry.Point2D)1 Pane (javafx.scene.layout.Pane)1 Line (javafx.scene.shape.Line)1 Text (javafx.scene.text.Text)1