I just play with XNA and I have several different models that I need to draw in each frame. at the moment, the Game object contains links to all my models and draws them one by one. Each with its own way of drawing - one has two separate textures, and the other can be mirrored on the other side, etc.
I was wondering if you can just add
public void Draw(SpriteBatch spriteBatch)
for all my models (of course, from BaseModel), and each class is responsible for drawing on its own, or maybe I should ensure that the classes set their data in accordance with the events (KeyboardState) in the Update method, and save all the graphic logic in the class Game.
Is there a preferred way to do this?
Typically, I have a base class that contains BaseModel, texture data, rotation and scale data, etc. For each type of actor in the game, I create a derived class. The base class provides the Draw method, which draws a model by default with texture, rotation, and scale data in the class. Derived classes can override it to attract an actor as they like.
Then I have a DrawableGameComponent that acts like my scene graph. It contains a list of all active objects of the actor. In the component drawing and updating methods, I repeat the list of participants and call them the drawing and updating methods.
... . , , ( ) , . - ... .
... , . , , , , . "Entity"
"List<Entity>"
List<Entity>
, , ... , . (.. , , ..).
, , . , ... , , , , , , : -P
Source: https://habr.com/ru/post/1706973/More articles:How to debug a single .cpp file in Visual Studio? - c ++SqlServer ASP.NET Session Replication - sql-serverHow to collect logs in jboss related to a single request? - javaRegex - Matching Exactly One Tag - htmlItemsSource in WPF simplified in C # programmatically - c #Changing the file name in CFMail - coldfusionHow to check if a tree has perfect match in linear time? - algorithmHow can I edit the selected ComboBox index? - .netManually updating WPF data - data-bindingКак изменить текст контроллера в URL-адресе ASP.NET MVC? - asp.net-mvcAll Articles