c# - Graphics not cleared XNA (Monogame) after switching screen -


we optimizing our first xna game, ran in problem:

there screenmanager manages screens. every time 'push' new screen remove (null) old screen, graphics should removed memory. seems not working, old graphics remain in background. using code remove previous screen:

private screen removescreen() {         screen screen = (screen)gamescreens.peek();         onscreenchange -= screen.screenchange;         game.components.remove(screen);         screen.contentmanager.unload ();         return gamescreens.pop();     } 

we have done research, , came across possible solution give every screen own contentmanager. when switch screens , nullify our old screen run contentmanager.unload() before nullify it. unfortunately not working (old graphics remain being drawn, weird flickering graphics). clarify problem made small youtube video, can see home screen, when go setting screen can see old homescreen while should removed: http://youtu.be/ii0qd6pusa8

i hope can us.

are clearing graphics device resource buffers before call draw code?

graphicsdevice.clear(color.cornflowerblue); 

if doing , problem persists, still have old screen component still.

try setting break point before , after screen remove code called , using debugger verify if components list still contains screen supposed removed.


Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -