Sign in to follow this  
Jamiernmd

XNA Question!

Recommended Posts

While fiddling with XNA I noticed something a bit wierd. I have a drawable game component which works as it should do. However, if I place a breakpoint in the update and draw functions, it hits the update function 30 times for every time it calls draw. The update function simply moves the object a few pixels, and without the break points it seems to function correctly, but with the break points in, the object jumps as it is not calling draw as often as it calls update. Does anyone know why this is happening? I hope this makes sense. cheers

Share this post


Link to post
Share on other sites
Are you sure they are called the same number of times without the break-point?
Try displaying a shared variable, that you increase in Update and decrease in Draw.
Just a guess, but perhaps when it breaks, the pause before you click continue is interpreted as a delay in the drawing or game logic, and it tries to catch up by running more updates before displaying again. Try putting a Sleep in it and see if you get the same behavior.

Share this post


Link to post
Share on other sites

This is actually by design, as explained here. Your breakpoint is making the render loop lag behind, so it'll call Update() a bunch of times while skipping Draw() in an effort to catch up. Please go badger Shawn that it is in fact not intuitive as I argued back then [smile]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this