0
\$\begingroup\$

I am using C# with MonoGame 3.6

A picture of what I mean: http://i.imgur.com/S3i5iB0.png You see, the little black box is drawn over the red box, because it is drawn before the red box gets drawn. Our view is diagonally forward, which means the red box should get drawn over the red one.

Now, I of course could loop through all entities and sort them by their Y coordinate, but I wanted to know if there was a faster way, as this would be totally inefficient if I had to do it on every game tick / every entity move.

Thank you!

\$\endgroup\$
0
\$\begingroup\$

Yes there is a way, You have set the SpriteSortMode in SpriteBath.Begin() to BackToFront or FrontToBack. Then use the SpriteBatch.draw() method that includes layer depth (https://msdn.microsoft.com/en-us/library/ff433989.aspx). They will be drawn in the proper order.

Note Layer Depth should be between 0 (front) and 1 (back).

\$\endgroup\$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.