/*
 * FXGL - JavaFX Game Library. The MIT License (MIT).
 * Copyright (c) AlmasB (almaslvl@gmail.com).
 * See LICENSE for details.
 */

package basics;

import com.almasb.fxgl.app.GameApplication;
import com.almasb.fxgl.app.GameSettings;
import com.almasb.fxgl.entity.Entity;
import com.almasb.fxgl.entity.EntityFactory;
import com.almasb.fxgl.entity.SpawnData;
import com.almasb.fxgl.entity.Spawns;
import com.almasb.fxgl.texture.AnimatedTexture;
import com.almasb.fxgl.texture.AnimationChannel;
import javafx.util.Duration;

import java.util.List;

import static com.almasb.fxgl.dsl.FXGL.*;

/**
 * @author Almas Baimagambetov (almaslvl@gmail.com)
 */
public class SpriteSheetAnimationSample extends GameApplication {
    @Override
    protected void initSettings(GameSettings settings) {

    }

    @Override
    protected void initGame() {
        getGameWorld().addEntityFactory(new FishFactory());

        spawn("fish");
    }

    public static class FishFactory implements EntityFactory {

        @Spawns("fish")
        public Entity newFish(SpawnData data) {
            var channel = new AnimationChannel(List.of(
                    image("fish/blue1.png"),
                    image("fish/blue2.png"),
                    image("fish/blue3.png")
            ), Duration.seconds(1.0));

            return entityBuilder()
                    .view(new AnimatedTexture(channel).loop())
                    .build();
        }
    }

    public static void main(String[] args) {
        launch(args);
    }
}

@@ -783,21 +783,16 @@
 tings) %7B
-%0A%0A   
  %7D%0A%0A    
@@ -877,20 +877,22 @@
 ory(new 
-Fish
+Zombie
 Factory(
@@ -911,20 +911,22 @@
  spawn(%22
-fish
+zombie
 %22);%0A    
@@ -952,20 +952,22 @@
 c class 
-Fish
+Zombie
 Factory 
@@ -1011,20 +1011,22 @@
 Spawns(%22
-fish
+zombie
 %22)%0A     
@@ -1049,12 +1049,14 @@
  new
-Fish
+Zombie
 (Spa
@@ -1157,18 +1157,23 @@
 ge(%22
-fish/blue1
+anim/Attack (1)
 .png
@@ -1207,18 +1207,23 @@
 ge(%22
-fish/blue2
+anim/Attack (2)
 .png
@@ -1257,18 +1257,73 @@
 ge(%22
-fish/blue3
+anim/Attack (3).png%22),%0A                    image(%22anim/Attack (4)
 .png
@@ -1361,11 +1361,11 @@
 nds(
-1.0
+0.5
 ));%0A

clean up sample, #816