Alternatives to multiple sprite batches for achieving 2D particle system depth
Posted
by
Ergwun
on Game Development
See other posts from Game Development
or by Ergwun
Published on 2012-05-10T14:08:15Z
Indexed on
2012/06/10
4:48 UTC
Read the original article
Hit count: 265
In my 2D XNA game, I render all my sprites with a single sprite batch using SpriteSortMode.BackToFront
and BlendState.AlphaBlend
.
I'm adding a particle system based on the App Hub particles sample. Since this uses
SpriteSortMode.Deferred
and BlendState.Additive
, I will need to have two SpriteBatch.Begin
/ SpriteBatch.End
pairs: one for 'regular' sprites, and one for particles.
In my top-down shooter, If I want to have explosions appear under planes, but above the ground, then I believe I will have to have three Begin
/End
pairs, first to draw everything under the explosions, then to draw the explosions, then to draw everything above the explosions. If I want to have particle effects at multiple different depths, then I'm going to need even more Begin
/End
pairs.
This is all easy to code, but I'm wondering if there is an alternative way to handle this?
© Game Development or respective owner