A visual profile is an .xml text file that contains data explaining what an Entity should look like.
In general, it does not affect the actual game logic at all, you can switch out visual profiles later after prototyping your game with simple tilepic style images or other visual profiles.
(the only exception to the above is when OnIdleLoop() or OnWalkLoop() script functions are used to detect when an animation is looping and base game logic on that.)
<resources>
//first define the visual profile
<profile name="car">
<anim state="idle_left" spritename="red_car" mirrorx="no"/>
</profile>
//now define any animations the visual profile uses, in this case, red_car
<sprite name="red_car">
<image fileseq="myRedCar_.png" leading_zeroes="3"/>
<translation origin="center"/>
<animation pingpong="no" loop="yes" speed="150"/>
</sprite>
</resources>
function OnInit() //run upon initialization
this:SetVisualProfile("car.xml", "red_car");
end
Easy, huh? This would play a single animation of the ‘car’ for the Entity’s visual at all times.
The file it would try to load is myRedCar_0000.png, myRedCar_0001.png and so on until it fails to find the next file in the sequence.
If myRedCar_0000.png isn’ found, it will also try to start at myRedCar_0001.png.
<sprite name="red_car">
<image file="carCrap.png"/>
<image file="carCrapPart2.tga"/>
<image file="AnotherFrame.jpg"/>
<image file="TheLastFrame.bmp"/>
<translation origin="center"/>
<animation pingpong="no" loop="yes" speed="150"/>
</sprite>
If we want an image or file sequence to automatically treat a specific color as transparent, you can add the “transparent_color” parameter.
//make white transparent
<image fileseq="myRedCar_.bmp" leading_zeroes="3" transparent_color="255,255,255" />
Alternatively, you may just use images that already have alpha information in them.
In the above example, idle_left is not a random animation name chosen, it is one of many pre-defined names that the engine will utilitize when deciding what image to display in the proper context.
So if your player is dying while facing right, the engine will check for die_right. If that isn’t found, it will check for die_left, if that fails, it will probably choose to use idle_right, and so on.
You can override and use additional custom named animations as well, for instance, the crayon.xml in the TreeWorld example uses a custom animation called climb.
You can get info on most of the other settings as well as a lot of optional settings we haven’t covered yet such as loading from a grid, setting animation timing of a specific frame, initial scale and alpha, rotational orientation and offset and more by checking out http://www.clanlib.org- /docs- /clanlib-0.8.0- /Overview- /sprites_resources.html.
Anim’s with these names are preferred by the engine when in the Idle state.
If you want a single frame only for your entity, use only this state. It’s the final fallback if everything else fails.
Anim’s with these names are preferred by the engine when in the Walk state.
Anim’s with these names are preferred by the engine when in the Pain state.
Anim’s with these names are preferred by the engine when in the Die state.
Anim’s with these names are preferred by the engine when in the Attack state.
Anim’s with these names are preferred by the engine when in the Pain state.