Animations!


An animation system has now been added which allows different spritesheets and configuration to be added to each entity actions. Here is a (very!) small sample of an attack animation and the associated config:

Which contains an idle animation and attack animation (cheating but actually using the same sprite sheet with the idle animation much slower!). The config which defines this unit is as follows:

{
    "Name": "Peasant",
    "Description": "Standard, cheap but weak unit",
    "Sprite": {
        "FilePath": "units/peasant.png",
        "PixelsPerUnitX": 625,
        "PixelsPerUnitY": 675,
        "CycleTimeSeconds": 10,
        "Repeats": true
    },
    "Tags": [
        "Unit"
    ],
    "Movement": {
        "Movement": 2,
        "BlocksEnemies": true,
        "AbilityConfig": {
            "PointCost": 1,
            "UsesPerTurn": 1
        }
    },
    "Attack": {
        "DirectAttacks": [
            {
                "Name": "Attack",
                "Detail": {
                    "CanMoveAndAttack": true,
                    "BasePower": 0.4,
                    "Selector": {
                        "AllowTags": [
                            "Unit"
                        ]
                    },
                    "TagPowerModifier": {},
                    "AbilityConfig": {
                        "PointCost": 1
                    }
                }
            }
        ],
        "Sprite": {
            "FilePath": "units/peasant.png",
            "PixelsPerUnitX": 625,
            "PixelsPerUnitY": 675,
            "CycleTimeSeconds": 0.25,
            "NumberOfLoops": 4
        }
    }
}

There are 2 Sprite blocks, one on the Root of the config which gives the idle animation and one on the Attack configuration which is applied to any attacks that are made (unless a specific one is given to a sub attack config). The new sprite configuration is pretty clever, simply give it a sprite sheet (or a static image) with other optional values:

KeyDescription
FilePath (Required)Points to the sprite sheet/image
PixelsPerUnit(X/Y)Determines the unit size of each frame. The sprite sheet will automatically be split into each frame starting top left, proceeding along the row row and then down to the next. If not added then it assumes that the file is a single static image.
CycleTimeSecondsHow quickly a complete cycle showing all frames takes.
FramerateSimilar to the CycleTimeSeconds but allows the specific framerate (frames per second) to be defined.
RepeatsDefine if its a continuous animation. For example, an idle animation repeats, a single attack does not. Animations that do not repeat complete for their entire duration and don’t get interrupted.
NumberOfLoopsHow many loops of the animation to complete before it is finished.

With the values give, it will automatically process the sprite sheet and incorporate it into the action at the particular level that is associated with. In this case the main attack confg but could be sub attacks, movement, capture etc.

More specific sub-mods are in the plan e.g movement in the cardinal directions (so having 4 for the set up, down, left and right which play as the entity moves) and any other specifics for other actions that I can think of. The system is generic such that the config is the same for each animation and all that is needed is adding to the format and adding the correct hook.

For illustration, the above units graphics are defined by this single example sprite sheet peasant.png:

,

Leave a Reply

Your email address will not be published. Required fields are marked *