@Neurological wrote:
While I was porting and reorganizing code from Unity to fit my workflow into monogame started to think how to deal with Update/Draw methods and which is the best or more convenient method.
In Unity since I never liked the MonoBehaviour approach of having too many Update calls all over the palce, made a hub with one single Update call that calls virtual methods from component that would subscribe to it, with a simple for loop.
I see monogame has this sort of method in palce already having one Update and Draw call from the Game based class. So I reorganized my code one way, my Game class has also other classes in it with each their own function, for example I got a Rendering class that holds all the info regarding what to render and a collection of components that need to be drawn. So from the Game class in Draw I just call a method in Rendering that does a loop trough the active component and draw the stuff on screen.
Same goes for other things like audio, input and animation stuff. So in the end would have one Update and one Draw that calls methods in other classes that runs loops to do whatever it need to do.
My doubt is that maybe isn't the best approach to this and maybe I should have multiple Update calls using GameComponents, how do you guys organize your code with this? Also is a for or foreach loop to iterate trough the list of components to Draw/Update the right method to do so?
Thanks.
Posts: 2
Participants: 2