How to prevent the XNA component from drawing when it is turned off?

I am making a 2d game in XNA. When using flexible gaming components, which are better for performance?

1. When the component is not on the screen, remove it from the list of components and add it to the screen.

2. When its splash screen does not start its drawing function (using the “awake” bool field and if the statement around everything in the drawing function)

I am using method 2 at the moment and it works great. Its convenient tool for component layout will not change (if I delete and add them again, and I need more code to manage this) In fact, it just seemed to me that if it is not included in the list of components, it will not be updated, and I need something else to keep track of whether its screen is on screen or not.

Also, I do not have a fantastic version of a visual studio with a profiler, so I just ask here what people think from their experience.

+5
source share
1 answer

SpriteBatch - , . .

, , , , . - , ( ). spriteBatch.Draw() CPU GPU . , spriteBatch.End(). , spriteBatch.End() . (, Begin()). , spriteSortMode.Imediate , GPU ()).

, Begin() End() , , , , , .

, . GPU...

+5

All Articles