XNA Question!

Started by
2 comments, last by Jamiernmd 14 years, 2 months ago
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
Advertisement
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.

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]
Rim van Wersch [ MDXInfo ] [ XNAInfo ] [ YouTube ] - Do yourself a favor and bookmark this excellent free online D3D/shader book!
I thought it might be something like that. When it runs normally it is only calling update once per draw.

Thanks for your help!

This topic is closed to new replies.

Advertisement