Before seeing the utility of the variables, we will create widgets.
The widgets are small graphic elements which are superimposed on the background.
Draw an unspecified object, for example an apple, with your preferred drawing editor. Insert the file pomme.bmp thus created in the "data/0/" folder. Note: other types of format are accepted, like jpg, or any other image format supported by Irrlicht.
Now, in XML file, just add after the opening markers < node0... > the following line:
<widget widgetPicture="pomme.bmp" skyboxPart="2" posX="0" posY="0" />
Small summary: your XML file should be now:
<?xml version="1.0"?>
<general>
<normalMouse nbPictures="1" timeAnimation="0" />
<eventMouse nbPictures="4" timeAnimation="300" />
</general>
<variables>
<variable camembert="5" />
<variable emmental="5" />
</variables>
<sounds>
</sounds>
<nodes>
<node0 north="1">
<widget widgetPicture="pomme.bmp" skyboxPart="2" posX="0" posY="0" />
<mechanism clickX="-0.948778" clickY="-0.218659" clickZ="-0.228055" clickRadius="0.05" newNode="45">
<consequenceSetVar variable="camembert" newValue="10" />
<consequenceIncrVar variable="emmental" incrementation="-1" />
</mechanism>
</node>
<node1 south="0">
</node>
<node45 south="0">
</node>
</nodes>
Press W in the game to show in the console all the widgets of the current node.
You can create an animated widget, adding the attributes "nbImages" (number of pictures in the animation) and "timeOneImage" (time before passing to the following picture, in miliseconds). In this case, you must create one picture with the different pictures of the animation, like the "example/data/1/widget3.bmp" file. If you don't want the animation to be in a non-stop loop, you can also add another parameter, "nbTimesAnimation", giving the number of images before the animation stop. See the example game to understand.
The face where the apple was put is defined by the value of skyboxPart:
The position where the apple was put is defined by the values of posX and posY, in pixels, from the top-right of the background image.