As there was a certain request here is how I brought animated Creeps into the Game. This is not going to be a "copy all the code -> working" thread, I will give you a pseudocodish step by step instruction but coding will happen on your side
There are some assumtions I made:
- The creep has 3 animations: Normal, Low (played when under 30% health) and a death animation
- Each animations is in its own file
- Animations are oneliner (just like explosion.png)
Shorty about how the enemyXML -> enemyData : Contentpipeline imports and read xml, then it processes the strings from the xml into textures in an enemyContent object and write this into the compiled content file. This file can be opened and is written
Ok now a step by step instruction:
- In ContentPipeline Project
- In Enemy Content add 3 Textures for our 3 animations.
- under " [ContentSerializerIgnore]" add 3 strings for the texture paths.
- Now open EnemyImporter and in the part where all the tag are read copy "TexturePath = e.Attribute("Texture").Value" 3 times and rename "Texture" into the corresponding names of your animation tags ("deathAnimation","lowAnimation"
and "normalAnimation" for me).
- Go into EnemyProcessor and copy the texture loading stuff 3 times and change variales to match your fields.
- Last but not least here open the EnemyDataWriter and again copy " output.WriteObject(value.Texture);" three time and change "value.Texture" into your field.
- Now switch to Engine Project
- Add 3 Animated Sprites to EnemyData.cs
- Open EnemyDataReader and add a function which generates a looping AnimatedSprite from a texture. then call this function in new EnemyData part, passing the textures with "input.ReadObject<Texture2D>()". Make sure you keep the order you wrote
it to the stream in the EnemyDataWriter.
Now you have your enemyData populated with AnimatedSprites. All you need to do now is open up GameVisuals and add you drawing logic. This is left as an excercise to the thoughtful reader ;)
Hope this helps you a bit with getting startet!