use of com.almasb.fxgl.animation.Animation in project FXGL by AlmasB.
the class UIFactory method translate.
default Animation<?> translate(Node node, Point2D from, Point2D to, Duration delay, Duration duration, Runnable onFinishedAction) {
Animation<?> anim = new Animation<Point2D>(delay, duration, 1, new AnimatedPoint2D(from, to)) {
@Override
public void onProgress(Point2D value) {
node.setTranslateX(value.getX());
node.setTranslateY(value.getY());
}
};
anim.setOnFinished(onFinishedAction);
return anim;
}
use of com.almasb.fxgl.animation.Animation in project FXGL by AlmasB.
the class MarioApp method initPhysics.
@Override
protected void initPhysics() {
getPhysicsWorld().addCollisionHandler(new CollisionHandler(MarioType.PLAYER, MarioType.COIN) {
@Override
protected void onCollisionBegin(Entity player, Entity coin) {
coin.getComponent(CollidableComponent.class).setValue(false);
Animation<?> anim = Entities.animationBuilder().duration(Duration.seconds(0.5)).interpolator(Interpolators.ELASTIC.EASE_IN()).scale(coin).from(new Point2D(1, 1)).to(new Point2D(0, 0)).buildAndPlay();
anim.setOnFinished(() -> coin.removeFromWorld());
}
});
getPhysicsWorld().addCollisionHandler(new CollisionHandler(MarioType.PLAYER, MarioType.DOOR) {
@Override
protected void onCollisionBegin(Entity player, Entity door) {
getDisplay().showMessageBox("Level Complete!", () -> {
System.out.println("Dialog closed!");
});
}
});
}
use of com.almasb.fxgl.animation.Animation in project FXGL by AlmasB.
the class UIFactory method scale.
default Animation<?> scale(Node node, Point2D from, Point2D to, Duration delay, Duration duration, Runnable onFinishedAction) {
Animation<?> anim = new Animation<Point2D>(delay, duration, 1, new AnimatedPoint2D(from, to)) {
@Override
public void onProgress(Point2D value) {
node.setScaleX(value.getX());
node.setScaleY(value.getY());
}
};
anim.setOnFinished(onFinishedAction);
return anim;
}
Aggregations