SAP Devlog: 4/2/2025

Hello!

I am here to rant about D.A.J., Dynamic Animation JSON.

Look at this:

{
        "animation_order": ["Spawn"],
        "animation_data": [
                {"Name": "Spawn", "Asset": "Medal-box", "Animated": false},

                {"Name": "Spawn-OG", "Asset": "Medal-box-Spawn", "FPS": 30, "Animated": true, "Animation_Frames": 4},
                {"Name": "Line", "Asset": "Medal-box-Line", "FPS": 15, "Animated": true, "Animation_Frames": 5},
                {"Name": "Final", "Asset": "Medal-box-Final", "Animated": false}
        ]
}

That code right there could make it so that it A, switches from image to image to play animations, and B, controls what order it is, and in V2 (or V1.1, idfk) it will do more obviously, but in V1, that’s the basically of it.

These are the functions controlling it.

override public function new(file:String, assetFolder:String) {
                super();

                this.assetFolder = assetFolder;

                setPosition(HORIZONTAL_POSITION, VERTICAL_POSITION);

                jsonData = FileManager.getJSON(FileManager.getDataFile('${file}.json'));
                trace(jsonData);

                loadAnim(0);
        }

        public function loadAnim(index:Int)
        {
                curAnimIndx = index;

                var data:AnimData = jsonData.animation_data[getAnimIndex(jsonData.animation_order[index])];

                var asset:String = data.Asset;
                var name:String = data.Name;
                var fps:Float = data.FPS;
                var animated:Bool = data.Animated;
                var anim_frames:Int = data.Animation_Frames;

                loadGraphic(FileManager.getImageFile('${assetFolder}/${asset}'), animated, 32, 64);

                if (animated)
                {
                        var i:Int = 0;
                        var anim_frmes:Array<Int> = [];

                        while (anim_frmes.length < anim_frames - 1)
                        {
                                anim_frmes.push(i);
                                i++;
                        }

                        animation.add('Animation', anim_frmes, fps, false);

                        animation.play('Animation');
                }

                trace(name);

                Global.scaleSprite(this, -2);
        }

        override function update(elapsed:Float) {
                super.update(elapsed);

                if (animation.finished && curAnimIndx != jsonData.animation_order.length - 1)
                {
                        curAnimIndx++;
                        loadAnim(curAnimIndx);
                }
        }


        public function getAnimIndex(name:String):Int
        {
                for (i in 0...jsonData.animation_data.length) {
                        if (jsonData.animation_data[i].Name == name)
                        {
                                return i;
                        }
                }

                return 0;
        }


        public function getAnimData(name:String):AnimData
        {
                for (i in 0...jsonData.animation_data.length) {
                        if (jsonData.animation_data[i].Name == name)
                        {
                                return jsonData.animation_data[i];
                        }
                }

                return jsonData.animation_data[0];
        }

Pretty simple right? If you know haxe anyway.

Anyway that’s it, idk when or if I will release it separate from SAP but yeah,

10
Subscribe to my newsletter

Read articles from Sin Consistencia directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Sin Consistencia
Sin Consistencia

I don't like doing what other people do.