Filed under xna
I've been messing around recently with a really cool particle engine for XNA called Mercury Particle Engine. This engine looks to have some great features and an active development cycle but the documentation can be very lacking.
One query that I keep seeing on their forums is how to actually go about and include it in a simple XNA 4.0 project.
I have attached a simple working project below but if you want to manually setup the particle engine in your existing project here are the steps you'll need to do:
- Downloaded Mercury Particle Engine 3.1 for XNA 4.0 (Binaries)
- Unblocked the zip file (right click the file and click on Unblock).
- Open Visual Studio 2010 and create a new Windows XNA 4 project.
- Copy the ProjectMercury.dll and ProjectMercury.ContentPipeline.dll files and place these into your game project in the root level or in a folder called ParticleEngine, whichever you choose.
- Check the properties of both files and set the Build Action to 'Content' in Visual Studio.
- Add a reference to the file ProjectMercury.dll in your game project.
- Add a reference to the files ProjectMercury.dll and ProjectMercury.ContentPipeline.dll in your content project.
- Copy the EffectLibrary and Textures from the editor example into your content project (so you now have all the textures and xml files at your disposal).
- Do a build and more than likely you will get some errors about some of the Effect XML files. This appeared to be down to 3 of them using the word 'True' instead of 'true' (all lowercase) on certain sections so replaced them and everything should build for you.
- Run through the steps from this blog article: http://xnacoding.blogspot.com/2010/07/how-to-mercury-particle-engine.html
- You need to make one change to the code from link above. This is where I stumbled initially. The LoadContent method should contain the following code rather than the code from that example:>
// load particle effects
myEffect = Content.Load(@"EffectLibrary\BasicExplosion");
When you build and run your project you should now be able to left mouse click and see an explosion particle effect on screen. Pretty cool! If you want to run a different effect simple rename BasicExplosion in the code above to whatever filename is on the XML file in the Effect folder you imported. Just be sure not to include the '.xml' extension.
Click here to download a sample XNA 4 project with Mercury Particle Engine.