Skip to content

Fixes issue #1227 #1230

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions fxgl-samples/src/main/java/sandbox/anim/AnimSample.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
package sandbox.anim;

import com.almasb.fxgl.animation.Animation;
import com.almasb.fxgl.animation.AnimationBuilder;
import com.almasb.fxgl.app.GameApplication;
import com.almasb.fxgl.app.GameSettings;
import com.almasb.fxgl.core.util.LazyValue;
Expand Down Expand Up @@ -41,10 +42,12 @@ protected void initSettings(GameSettings settings) {
}

private Animation<?> anim;
private AnimationBuilder.ScaleAnimationBuilder builder;

@Override
protected void initInput() {
onKeyDown(KeyCode.F, "f", () -> {

anim.onUpdate(0.5);

getGameWorld().getEntities().forEach(e -> {
Expand All @@ -54,6 +57,8 @@ protected void initInput() {
onKeyDown(KeyCode.G, "g", () -> anim.stop());
onKeyDown(KeyCode.Q, "q", () -> anim.pause());
onKeyDown(KeyCode.E, "e", () -> anim.resume());
onKeyDown(KeyCode.R, "r", () -> anim.start());
onKeyDown(KeyCode.P, "p", () -> builder.buildAndPlay());
}

private LazyValue<Image> image = new LazyValue<>(() -> {
Expand Down Expand Up @@ -99,16 +104,18 @@ protected void initGame() {
// .onProgress(value -> System.out.println(value))
// .buildAndPlay();

animationBuilder()
builder= animationBuilder()
.onCycleFinished(() -> System.out.println("Cycle finished"))
.onFinished(() -> System.out.println("Anim finished"))
.duration(Duration.seconds(1))
.repeat(5)
.scale(e)
.origin(new Point2D(40, 40))
.from(new Point2D(1, 1))
.to(new Point2D(2, 2))
.buildAndPlay();
.to(new Point2D(2, 2));

anim = builder.build();
builder.buildAndPlay();;
}

public static class EFactory implements EntityFactory {
Expand Down