About Visual Profiles

About Visual Profiles

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.)

Here is a very small but valid .xml visual profile called car.xml:

<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>

Now, in an Entity’s script, you would add this to its OnInit():

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.

Note about loading a file sequence:

If myRedCar_0000.png isn’ found, it will also try to start at myRedCar_0001.png.

Instead of loading a file sequence, you can also individually specify each frame you want like this:

<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>

Note about colorkey:

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.

Visual State Hinting

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.

A myriad of options for loading your sprite

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.

Summary
About Visual ProfilesA visual profile is an .xml text file that contains data explaining what an Entity should look like.
Related Constants
Idle State AnimsAnim’s with these names are preferred by the engine when in the Idle state.
idle_leftIf you want a single frame only for your entity, use only this state.
idle_right
idle_up
idle_down
idle_up_left
idle_down_left
idle_up_right
idle_down_right
Walk State AnimsAnim’s with these names are preferred by the engine when in the Walk state.
walk_left
walk_right
walk_up
walk_down
walk_up_left
walk_down_left
walk_up_right
walk_down_right
Run State AnimsAnim’s with these names are preferred by the engine when in the Run state.
run_left
run_right
run_up
run_down
run_up_left
run_down_left
run_up_right
run_down_right
Pain State AnimsAnim’s with these names are preferred by the engine when in the Pain state.
pain_left
pain_right
pain_up
pain_down
pain_up_left
pain_down_left
pain_up_right
pain_down_right
Die State AnimsAnim’s with these names are preferred by the engine when in the Die state.
die_left
die_right
die_up
die_down
die_up_left
die_down_left
die_up_right
die_down_right
Attack1 State AnimsAnim’s with these names are preferred by the engine when in the Attack state.
attack1_left
attack1_right
attack1_up
attack1_down
attack1_up_left
attack1_down_left
attack1_up_right
attack1_down_right
Special1 State AnimsAnim’s with these names are preferred by the engine when in the Pain state.
special1_left
special1_right
special1_up
special1_down
special1_up_left
special1_down_left
special1_up_right
special1_down_right

Related Constants

Summary
Idle State AnimsAnim’s with these names are preferred by the engine when in the Idle state.
idle_leftIf you want a single frame only for your entity, use only this state.
idle_right
idle_up
idle_down
idle_up_left
idle_down_left
idle_up_right
idle_down_right
Walk State AnimsAnim’s with these names are preferred by the engine when in the Walk state.
walk_left
walk_right
walk_up
walk_down
walk_up_left
walk_down_left
walk_up_right
walk_down_right
Run State AnimsAnim’s with these names are preferred by the engine when in the Run state.
run_left
run_right
run_up
run_down
run_up_left
run_down_left
run_up_right
run_down_right
Pain State AnimsAnim’s with these names are preferred by the engine when in the Pain state.
pain_left
pain_right
pain_up
pain_down
pain_up_left
pain_down_left
pain_up_right
pain_down_right
Die State AnimsAnim’s with these names are preferred by the engine when in the Die state.
die_left
die_right
die_up
die_down
die_up_left
die_down_left
die_up_right
die_down_right
Attack1 State AnimsAnim’s with these names are preferred by the engine when in the Attack state.
attack1_left
attack1_right
attack1_up
attack1_down
attack1_up_left
attack1_down_left
attack1_up_right
attack1_down_right
Special1 State AnimsAnim’s with these names are preferred by the engine when in the Pain state.
special1_left
special1_right
special1_up
special1_down
special1_up_left
special1_down_left
special1_up_right
special1_down_right

Idle State Anims

Anim’s with these names are preferred by the engine when in the Idle state.

idle_left

If you want a single frame only for your entity, use only this state.  It’s the final fallback if everything else fails.

idle_right

idle_up

idle_down

idle_up_left

idle_down_left

idle_up_right

idle_down_right

Walk State Anims

Anim’s with these names are preferred by the engine when in the Walk state.

walk_left

walk_right

walk_up

walk_down

walk_up_left

walk_down_left

walk_up_right

walk_down_right

Run State Anims

Anim’s with these names are preferred by the engine when in the Run state.  If not found, Walk anims will be used.

run_left

run_right

run_up

run_down

run_up_left

run_down_left

run_up_right

run_down_right

Pain State Anims

Anim’s with these names are preferred by the engine when in the Pain state.

pain_left

pain_right

pain_up

pain_down

pain_up_left

pain_down_left

pain_up_right

pain_down_right

Die State Anims

Anim’s with these names are preferred by the engine when in the Die state.

die_left

die_right

die_up

die_down

die_up_left

die_down_left

die_up_right

die_down_right

Attack1 State Anims

Anim’s with these names are preferred by the engine when in the Attack state.

attack1_left

attack1_right

attack1_up

attack1_down

attack1_up_left

attack1_down_left

attack1_up_right

attack1_down_right

Special1 State Anims

Anim’s with these names are preferred by the engine when in the Pain state.

special1_left

special1_right

special1_up

special1_down

special1_up_left

special1_down_left

special1_up_right

special1_down_right

The Entity object.
A state that causes an entity to stop and play his idle animation.
A state that causes an entity to play his walk animation and move in the direction he’s current facing at the speed set in Entity::SetDesiredSpeed.
A state that causes an entity to play his run animation and move in the direction he’s current facing at the speed set in Entity::SetDesiredSpeed.
A state that causes an entity to stop moving and play his attack animation.
A state that causes an entity to stop moving and play his die animation.
A state that causes an entity to stop moving and play his attack animation.