This project is read-only.

Emitter Usage

To make emitters work, it is important to make sure it's properly initialized and loaded. Emitters will not work unless they have been initialized and loaded first.

Emitters have an Initialize() method that makes sure to do all the initialization of the emitter, such as creating the particle arrays. If you use XNA, you can just initialize the emitter in the XNA built-in method conveniently called: Initialize(). Emitters also have a method called LoadContent() that is responsible of loading the emitter texture. Again, if you run XNA, just call this method inside the XNA method: LoadContent()

To make an emitter release particles, you have the Trigger() method on the emitter object. Trigger() takes in a position of where the release should happen. This release position is then enqueued for later when we update the emitter. It is made that way to make it possible to release particles several places on the screen simultaneously.

As mentioned before, emitters need to be updated. The update makes sure that the particles are updated with new positions and released at the correct positions. This method is called Update() and should be called inside your game loop (Called Update() in XNA)

A note on loading textures
Basically you have two options of loading a texture, you can load a texture yourself and set the ParticleTexture property directly, or you can set the ParticleTextureAssetName and let the emitter load the asset itself during the LoadContent methd. Here's example code for each method.

Texture2D particleImage = this.Content.Load<Texture2D>("Content\\Textures\\MyParticleTexture");
myEmitter.ParticleTexture = particleImage;

this.GraphicsDeviceManager = new GraphicsDeviceManager(this);


--or--

myEmitter.ParticleTextureAssetName = "Content\\Textures\\MyParticleTexture";
myEmitter.LoadContent(this.Content);


Both of those code samples accomplish the same thing. The reason the second method exists is to allow serialization of the texture asset name. That way the .em file can specifiy "Content\\Textures\\MyParticleTexture" in the xml and it will be loaded automatically.

Last edited Aug 24, 2009 at 4:26 PM by JimJams, version 1