|
| 1 | +--- |
| 2 | +author: Furo |
| 3 | +desc: How to make custom icons. |
| 4 | +lastUpdated: 2025-05-02T19:10:00.000Z |
| 5 | +title: Making Custom Icons |
| 6 | +--- |
| 7 | +# Making Custom Icons |
| 8 | + |
| 9 | +To start making your icon you need to see whenever it is animated or not |
| 10 | + |
| 11 | +**Note:** If your icon doesn't need to be scaled nor flipped nor be antialiased nor to be animted you can just put your icon direcly in to ``./images/icons/`` and just named ``iconName.png`` (Replace it with your actual icon name btw) |
| 12 | +And if you followed that note you dont need to read the rest since it needs and icon data which the old format doesnt have :P |
| 13 | + |
| 14 | +Make a folder in ``./images/icons`` with the name of your icon and place it the png (and the xml if its animated) and then create a file named ``data.xml`` if you don't need to change specifications about the icon like default scale, facing direction and antialiasing. |
| 15 | + |
| 16 | +**Important note:** The xml for the animated icon you be named ``icon.xml`` and the png should be named ``icon.png`` both these files should be your icon name folder alonside the data if you have/need one |
| 17 | + |
| 18 | +If the icon is not animated |
| 19 | +```xml |
| 20 | +<!DOCTYPE codename-engine-icon> |
| 21 | +<icon scale="1" facing="left" antialiasing="true" /> |
| 22 | +``` |
| 23 | + |
| 24 | +And for animated icons this is going to be different because every animated icon is different |
| 25 | +```xml |
| 26 | +<!DOCTYPE codename-engine-icon> |
| 27 | +<icon scale="3" facing="left" antialiasing="false" offsetX="0" offsetY="0"> |
| 28 | + <!-- adds an animation for type neutral with the anim idle0 with an y offset of -15 and not moving with fps=0 --> |
| 29 | + <anim name="neutral" anim="idle0" looped="false" offsetY="-15" fps="0"/> |
| 30 | + |
| 31 | + <!-- adds a transition from neutral to winning with a fps value of 10 fps and y offset of -15 --> |
| 32 | + <transition from="neutral" to="winning" anim="confirm0" fps="10" offsetY="-15"/> |
| 33 | + |
| 34 | + <!-- this sets the percentage from 0 to the next step (added later) to be specified as a neutral type --> |
| 35 | + <step percent="0" type="neutral"/> |
| 36 | + |
| 37 | + <!-- doing the same as before but for winning --> |
| 38 | + <anim name="winning" anim="confirm-hold0" looped="false" offsetY="-15" fps="0"/> |
| 39 | + <transition from="winning" to="neutral" anim="unconfirm0" fps="10" offsetY="-15"/> |
| 40 | + |
| 41 | + <!-- with this added in combination of the previous step node will make the icon go to its winning state at 80% of health and go back to neutral below that --> |
| 42 | + <step percent="80" type="winning"/> |
| 43 | +</icon> |
| 44 | +``` |
| 45 | + |
| 46 | +If you did it correctly you should have a icon folder looking like this |
| 47 | + |
| 48 | +<img src="./making-custom-icons.png" alt="Image showing a folder with files in a disposition for custom health icons"> |
| 49 | + |
| 50 | +If you need an example of a icon with an animated transition between winning and neutral you can [download the example here](root/file-uploads/freeplay-bf-icon-example.zip) |
| 51 | + |
| 52 | +## Structure |
| 53 | + |
| 54 | +```xml |
| 55 | +<icon antialiasing="true"/> |
| 56 | +``` |
| 57 | +or |
| 58 | +```xml |
| 59 | +<icon antialiasing="true"> |
| 60 | + <!-- Icon Nodes Here --> |
| 61 | +</icon> |
| 62 | +``` |
| 63 | + |
| 64 | +Optional Parameters: |
| 65 | + |
| 66 | +- ``offsetX`` pretty self explanatory |
| 67 | +- ``offsetY`` also pretty self explanatory |
| 68 | +- ``scale`` i think you get it now |
| 69 | +- ``facing`` the direction the icon should face. (can be `left` or `right`) |
| 70 | +- ``antialiasing`` If false makes the icon look sharper (can be `true` or `false`) |
| 71 | + |
| 72 | +```xml |
| 73 | +<transition anim="idle0" from="winning" to="losing" /> |
| 74 | +``` |
| 75 | + |
| 76 | +Required parameters: |
| 77 | +- ``anim`` which is the name of the animation in the spritesheet xml/atlas symbol name. |
| 78 | +- ``from`` which is the name of the state you are going from (default possible values: "winning", "neutral", "losing" (new ones can be created using the <syntax lang="xml"><step></syntax> node)). |
| 79 | +- ``to`` which is the name of the state you are going to (default possible values: "winning", "neutral", "losing" (new ones can be created using the <syntax lang="xml"><step></syntax> node)). |
| 80 | + |
| 81 | +Optional Parameters: |
| 82 | + |
| 83 | +- ``offsetX`` pretty self explanatory |
| 84 | +- ``offsetY`` also pretty self explanatory |
| 85 | +- ``fps`` framerate of which the animation plays at (defaults to 24) |
| 86 | + |
| 87 | +```xml |
| 88 | +<anim anim="idle0" name="winning" /> |
| 89 | +``` |
| 90 | + |
| 91 | +Required parameters: |
| 92 | +- ``anim`` which is the name of the animation in the spritesheet xml/atlas symbol name. |
| 93 | +- ``name`` which is the name of the current state of the icon (default possible values: "winning", "neutral", "losing" (new ones can be created using the <syntax lang="xml"><step></syntax> node)). |
| 94 | + |
| 95 | +Optional Parameters: |
| 96 | + |
| 97 | +- ``offsetX`` pretty self explanatory |
| 98 | +- ``offsetY`` also pretty self explanatory |
| 99 | +- ``fps`` framerate of which the animation plays at (defaults to 24) |
| 100 | +- ``looped`` whenever or not the animation is looped (defaults to true) |
| 101 | + |
| 102 | +```xml |
| 103 | +<step percent="80" name="winning" /> |
| 104 | +``` |
| 105 | + |
| 106 | +Required parameters: |
| 107 | +- ``percent`` which is the name of the animation in the spritesheet xml/atlas symbol name. |
| 108 | +- ``name`` state of the icon to be set (default possible values: "winning", "neutral", "losing", or basically anything since you are making a custom step). |
0 commit comments