@tval wrote:
I am attempting to draw my tiled map (using primitives) with my character (using spritebatch) over the top. However, my character always appears under the tiled map or the character appears in part of the map and not another. I would like to draw the character above most of the tiled map layers, but underneath a semi-transparent layer. Note, I am using MG.Extended. Below is my method to draw each:
SpriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.Default, RasterizerState.CullNone, null, _camera.GetViewMatrix());
var projectionMatrix = Matrix.CreateOrthographicOffCenter(0, Game.GraphicsDevice.Viewport.Width, Game.GraphicsDevice.Viewport.Height, 0, 0f, -1f);
if (layer.Name == "something")
{
tiledMapEffect."stuff" = ...stuff;
tiledMapEffect.WorldMatrix.Translation = vector3(0,0, 0f);
tiledMapEffect.ProjectionMatrix = projectionMatrix;
...
GraphicsDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, model.TrianglesCount);
}
else
Diddo as above except my depth is 1f._spriteBatch.Draw(texture, ...other stuff..., layerDepth: 0.5f);
SpriteBatch.End();
How do I draw using both primitives and spritebatch and interspersed depths?
Posts: 4
Participants: 2