Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I am making a game on a WP7 device using C# and XNA. I have a system where I always want the object the user is touching to be brought to the top, so every time it is touched I add float.Epsilon to its draw depth (I have it set so that 0 is the back and 1 is the front).

On the Emulator that all works fine, but when I run it on my device the draw depths seem to be completely random.

I am hoping that anybody knows a way to fix this. I have tried doing a Clean & Rebuild and uninstalling from the device but that is no luck. My call to spritebatch.Begin is:

spriteBatch.Begin(SpriteSortMode.FrontToBack, BlendState.AlphaBlend);

and to draw I use

spriteBatch.Draw(Texture, new Rectangle((int)X, (int)Y, (int)Width, (int)Height), null, Color.White, 0, Vector2.Zero, SpriteEffects.None, mDrawDepth);

Where mDrawDepth is a float value of the draw depth (likely to be a very small number; a small multiple of float.Epsilon.

Any help much appreciated, thanks!

share|improve this question
add comment

1 Answer

up vote 4 down vote accepted

This note from MSDN seems relevant:

On ARM systems, the value of the Epsilon constant is too small to be detected, so it equates to zero. You can define an alternative epsilon value that equals 1.175494351E-38 instead.

share|improve this answer
    
Thank you! I know in C# you can do Class Extensions but do you know if there is a way that I could add it so that I can do something like float.ARMEpsilon? –  Luke Sep 25 '12 at 10:52
    
I only know of extension methods, so you could add float.ARMEpsilon() (or Single.ARMEpsilon()) :/ –  melak47 Sep 25 '12 at 11:09
    
After searching around and trying it out it seems you can't do static extension methods as extension methods (on an object) are already static. I've just done a private const float at the top of the file that uses it. –  Luke Sep 25 '12 at 11:20
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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