Inherit From DrawableGameComponent
|Top Previous Next|
DPSF provides two dll files: DPSF.dll and DPSFAsDrawableGameComponent.dll. You should only reference one of them in your project, or else you will get conflicting namespaces.
DPSF.dll is the default file to reference. If you want your DPSF particle systems to inherit from the Microsoft.XNA.Framework.DrawableGameComponent class, then reference the DPSFAsDrawableGameComponent.dll instead.
The advantage to using the DPSFAsDrawableGameComponent.dll and having DPSF inherit from DrawableGameComponent is that the particle system's UpdateOrder and DrawOrder will be performed relative to all other drawable game components. If not inheriting from DrawableGameComponent, the UpdateOrder and DrawOrder only have an effect when used inside a Particle System Manager, and their UpdateOrder and DrawOrder are only relative to other particle systems in the same particle system manager.
If DPSF is set to inherit from DrawableGameComponent, particle systems are automatically added to the Game object's (given in the particle system constructor) components and the Update() and Draw() functions are automatically called by the Game object when it updates and draws the rest of its components. If the Update() and Draw() functions are called by the user anyways, they will exit without performing any operations, so it is suggested to include them anyways to make switching between inheriting and not inheriting from DrawableGameComponent seamless; just be aware that the updates and draws are actually being performed when the Game components are told to update and draw (i.e. when base.Update() and base.Draw() are called), not when these functions are being called. If inheriting from DrawableGameComponent and you want to force the updating or drawing of the particle system, this can be done by calling the UpdateForced() and DrawForced() functions respectively. Be aware however that this will cause the particle system to be updated / drawn twice per frame; once when it is explicitly called and once when the game components are updated / drawn.