Hi Mindok, I tend to do #2 in my games. Assuming you want to keep the resources from the other levels in memory, there isn't any performance advantage of #1. If you don't call the other level's Batch.draw() method, it won't cost any performance. Whatever objects you have will remain in GPU memory, but won't be drawn. In case you DON'T want to keep the other level's resources in memory, and plan to reload everything on level change, then you can just recrete a new Batch at that time. The only thing to avoid is Batch migration during a running game because there is some overhead with this.
Groups don't need to be touched. They are a way to segretate things inside of a Batch, which is handled automatically whenever adding an object to the Batch. Let me know if that make sense or not. Also, what type of game is this? -Ben On Friday, June 15, 2018 at 5:01:36 AM UTC+9, Mindok wrote: > > I was wondering if there are best/recommended practices on how to handle > batches and scenes and levels. > More particularly, if I have a Game Scene, and the game has multiple > different levels, the player can move between these levels, > what is a good way to implement this? > I can imagine a couple of options, but I don't know which is best: > > 1) The game scene has a batch, and when a level changes, the sprites of > the old level are turned off (sprite.batch = None, sprite.visible = False > or something else) > and the sprites of the new level are turned on (sprite.batch = > current_level_batch, sprite.visible = True or something else). > If sprite batches are messed with, how does this work with Ordered Groups? > Do you have to change them also? > > 2) Every level has its own batch. The Game Scene calls the draw function > of the level batch. > When player changes levels, you need to change its batch (and Ordered > Group?): player.batch = new_level_batch? > > Those are the ones I could think of. Are there others that are better? > If some of these are bad practice, an explanation would be appreciated. > -- You received this message because you are subscribed to the Google Groups "pyglet-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/pyglet-users. For more options, visit https://groups.google.com/d/optout.
