Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8576521
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:56:32+00:00 2026-06-11T19:56:32+00:00

I am making a game on a WP7 device using C# and XNA. I

  • 0

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!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T19:56:33+00:00Added an answer on June 11, 2026 at 7:56 pm

    The problem is your use of float.Epsilon. From the documentation:

    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.

    I expect that the emulator is not running a completely accurate emulation of ARM – which is why it works correctly on the emulator and not the device. (I’m not even sure the emulator is actually running ARM – it may well be x86.)


    It should be noted that adding epsilon to things and expecting the resulting value to be meaningful is highly risky. The value of float.Epsilon is the precision of 32-bit floating point numbers (on x86) around zero.

    At numbers of greater magnitude than zero, the precision delta becomes larger. There will come a point where adding float.Epsilon to a given value will give you exactly that value back.

    Without getting into a detailed description of how floating-point works, I will just point out that a 32-bit float (when considered in base-10) can store 6 (or so) significant digits.


    Personally I would recommend implementing your own ordering system. I’ve always found the layerDepth stuff in XNA kind of weak.

    Perhaps you’re drawing these components from a list? Just re-order the list when a component is touched?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm planning on making a casual word game for WP7 using XNA. The game
I am making a game, and have a Game model and a User model.
I am making a game engine using HTML5 canvas, and I have decided to
I'm making a game with XNA. I have my camera, my background and my
I'm making a game using XNA framework, so I use a lot functions that
I'm making a simple WP7 game and I have a little problem with orientation
I'm making a game engine in Javascript, and I want to have a camera
I am making a game for the Windows Phone using XNA framework C#. The
I'm making a game using cocos2d-iphone, I want's to rotate a Texture2D of maybe
I am making a game in java and I want to create a simulation

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.