Im trying to draw my player on the first layer of my map using BeforeDraw like so:
map.Layers.BeforeDraw += new xTile.Layers.LayerEventHandler(e_OnBeforeLayerDraw);
My handler & draw class look like this:
private void e_OnBeforeLayerDraw(object sender, xTile.Layers.LayerEventArgs layerEventArgs)
SpriteBatch spriteBatch = xdd.SpriteBatchAlpha;
public override void Draw(GameTime gameTime)
//world.DrawLevel(gameTime, GameRef.SpriteBatch, player.Camera);
This is my player.Draw()
public void Draw(GameTime gameTime, SpriteBatch spriteBatch)
The error appears in player.Draw() on my spriteBatch.Begin (first line). I get a "Begin cannot be called again until End has been successfully called".
I guess this is because xTile has started a begin somewhere and when the event handler fires off the .end() has not been reached. However, I need a begin() so I can put my Camera.Transformation Matrix in, or else my camera does not function properly.
Is there any way for me to fix this?
Any help is greatly appreciated.