From The Mana World
(Version 0.2)
(Added my suggestion)
Line 26: Line 26:


So if you want to load the playerset you just load player.xml and it takes care of loading all related images. Of course delays are defined in milliseconds.
So if you want to load the playerset you just load player.xml and it takes care of loading all related images. Of course delays are defined in milliseconds.
== Some attempt by Bjørn ==
A sprite is an object which can carry several animations, hence I call the root element the <code>sprite</code>. Also, I think we should seperately define animations in several directions. For now this example is based on the current playerset image, but by using multiple imagesets this could of course be split up.
Each <code>frame</code> and <code>frames</code> element can optionally have attributes <code>x</code> and <code>y</code> to specify an offset from the default drawing position for that frame. This will allow the animation of for example the hairset (or any equipment) to reuse the same frames with different offsets, and be defined exactly like below.
In the bow animation I've chosen a shortcut to specify different delays for different frames. I am undecided yet whether this is a nice feature or whether it'll be better to require multiple <code>frame</code> elements in such cases.
For the dead frame I have specified no direction attribute, which makes this animation independent of direction. Also, it includes an experimental suggestion on specifying that a random frame should be chosen.
<pre>
<sprite name="player">
<imageset name="base" src="player-male-base.png" width="64" height="64" />
<animation name="stand" direction="down">
  <frame imageset="base" index="0" />
</animation>
<animation name="stand" direction="left">
  <frame imageset="base" index="18" />
</animation>
<animation name="stand" direction="up">
  <frame imageset="base" index="36" />
</animation>
<animation name="stand" direction="right">
  <frame imageset="base" index="54" />
</animation>
<animation name="walk" direction="down">
  <frames imageset="base" start="1" end="6" />
</animation>
...
<animation name="sit" direction="down">
  <frame imageset="base" index="7" />
</animation>
...
<animation name="bow-attack" direction="down">
  <frames imageset="base" start="13" end="17" delays="5,5,5,10,50" />
</animation>
...
<animation name="dead">
  <random>
  <frame imageset="base" index="8" />
  <frame imageset="base" index="26" />
  <frame imageset="base" index="44" />
  <frame imageset="base" index="62" />
  </random>
</animation>
</sprite>
</pre>

Revision as of 17:47, 14 March 2006

This article is currently only a proposal

The features or design guidelines described in this article are only a proposal made by one or some persons. It has not been evaluated or accepted by the core development team yet. Feel free to add your personal opinion about them or make counter proposals.

After a mini-meeting between me and Doener we refined the model. Each animation will be defined by an xml document, here follows an example:

<?xml version="1.0"?>
<animation name="player">
	<spritemap name="misc" src="player-male-misc.png" width="64" height="64" />
	<spritemap name="stab" src="player-male-stab.png" width="64" height="64" />
	<spritemap name="bow" src="player-male-bow.png" width="64" height="64" />
 
	<action name="stand">
		<frame spritemap="misc" index="0" delay="0" />
	</action>
 
	<action name="walk">
		<frame spritemap="misc" index="0" delay="20" />
		<frame spritemap="misc" index="1" delay="20" />
	</action>
 
	<action name="bow-attack">
		<sequence spritemap="bow" start="0" end="5" delay="20" />
	</action>
</animation>

So if you want to load the playerset you just load player.xml and it takes care of loading all related images. Of course delays are defined in milliseconds.

Some attempt by Bjørn

A sprite is an object which can carry several animations, hence I call the root element the sprite. Also, I think we should seperately define animations in several directions. For now this example is based on the current playerset image, but by using multiple imagesets this could of course be split up.

Each frame and frames element can optionally have attributes x and y to specify an offset from the default drawing position for that frame. This will allow the animation of for example the hairset (or any equipment) to reuse the same frames with different offsets, and be defined exactly like below.

In the bow animation I've chosen a shortcut to specify different delays for different frames. I am undecided yet whether this is a nice feature or whether it'll be better to require multiple frame elements in such cases.

For the dead frame I have specified no direction attribute, which makes this animation independent of direction. Also, it includes an experimental suggestion on specifying that a random frame should be chosen.

<sprite name="player">
 <imageset name="base" src="player-male-base.png" width="64" height="64" />

 <animation name="stand" direction="down">
  <frame imageset="base" index="0" />
 </animation>
 <animation name="stand" direction="left">
  <frame imageset="base" index="18" />
 </animation>
 <animation name="stand" direction="up">
  <frame imageset="base" index="36" />
 </animation>
 <animation name="stand" direction="right">
  <frame imageset="base" index="54" />
 </animation>

 <animation name="walk" direction="down">
  <frames imageset="base" start="1" end="6" />
 </animation>
 ...

 <animation name="sit" direction="down">
  <frame imageset="base" index="7" />
 </animation>
 ...

 <animation name="bow-attack" direction="down">
  <frames imageset="base" start="13" end="17" delays="5,5,5,10,50" />
 </animation>
 ...

 <animation name="dead">
  <random>
   <frame imageset="base" index="8" />
   <frame imageset="base" index="26" />
   <frame imageset="base" index="44" />
   <frame imageset="base" index="62" />
  </random>
 </animation>
</sprite>