Im making a 2d game in XNA. I started off using drawable game components and was quite happy. Every sprite is derived from drawable-game-component and each one has its own begin/end statement (even each tile making up a wall). Ive since realised after reading around a bit that this is a bad way to do it for performance.
Now I'm wondering what is a good way to do it... Lets say for each room in my game I do...
_spritebatch.Begin(SpriteSortMode.Deferred,
BlendState.Opaque,
SamplerState.LinearClamp,
DepthStencilState.Default,
RasterizerState.CullNone,
null,
_camera.Transform);
for (each block in Blocklist)
{
_spritebatch.Draw(block._txture,
block._position + block._centerVect,
block.txtrect, block._color,
(float)block.txtrot,
block._centerVect,
1.0f,
SpriteEffects.None,
0f);
}
_spritebatch.End();
the reason I'm asking is I'll have to make loads of the fields in each block public so the Room class can get at them to do its _spritebatch.Draw eg. block._position
I'm assuming this wont really matter and performance will improve but is there any nicer architecture anyone can recommend to do this?
Also since that code is up there, can anyone comment on the SpriteBatch.Begin paramaters I'm using? Are they the fastest ones? All I need in there is the transform