Hello. I was wondering if there were any optimization benefits with drawing textures with only calling spritebatch.Begin() and spritebatch.End() once, as opposed to calling .Begin() and .End() for each texture.
I understand there are limitations to using this approach, such as not being able to change the SpriteSortMode and BlendState, but I am not worried about that. I am only curious about whether or not designing a drawing system like this would have a significant affect on a game's performance.
An explanation regarding the "expense" of calling a spritebatch's .Begin() and .End() functions would be appreciated!
Hello, please let me know if I'm being way too nit picky or paranoid about my game's performance with my query:
To see if my mouse intersecting a Rectangle (in XNA), I've thought of two ways:
1. Check if the object's Rectangle intersects with a new Rectangle created at the mouse's position. Or 2. Initialize a rectangle to follow the mouse around, and update its position every time Update() is called, and when the check occurs, simply provide the mouse's Rectangle.
Assuming the check is called very frequently (whenever other classes want to know if the mouse is hitting anything important), which method would be the most efficient? And, is this difference even significant?
I'm working on a game where I will manually construct a large number of Ship objects (100+), each with their own unique stats, but, of course, sharing the same properties and methods.
Someone suggested I should create a sub-class for each different ship to accomplish this, but this goes against my intuition. However, I don't know what would be bad about this approach either. This approach is tempting because I would be able to quickly access a particular subclass object with my IDE's auto-fill feature when I begin typing its name.
Is there a performance cost or disadvantage to creating sub-classes in this manner, where I could just create instances of the same class instead?