Hi all. I have a bunch of game entities, which I'm drawing with pyglet sprites. I'm interested in batching them for performance.
My issue is that each of my in-game entities has about a half-dozen frames of animation (for actions like walking, and facing left, facing right.) So currently I create one sprite for each animation frame, and my game_ent.draw() method selects the correct sprite based on what the entity is currently up to (eg. walking left) and calls sprite.draw(). This works. But now I come to rework it for batching, I realise I might be doing it wrong. Especially since, with things are they are, I can't batch all my sprites up without batch.draw() drawing *all* frames of animation for every game entity. I could set the unwanted sprites .visible attribute to False, but I suspect I'm swimming against the current here. Idea 1: Should I actually be creating one sprite for each game entity, and changing that sprite's Image dynamically in order to animate the sprite? If this works, then presumably I could batch up all these sprites with no problem. Presumably I should make sure all my images are coming from a single spritesheet, stored in a single Texture or TextureBin or whatever it is, then this won't have too bad a performance hit? (I can read up on this part) Other, less-promising ideas I've had, are: 2. I could set sprite.visible = False for all the unwanted frames. But then my batch is going to be full of sprites, only about 1/6th of which are actually visible at any time. 3. I could use an Animation in the sprite, instead of an Image. Set all of the Animation's Frame's duration's to None, and (somehow) choose the desired animation frame to animate the sprite. 4. I assume I shouldn't be trying to add and remove things from the batch dynamically, depending on what I want drawn. Thanks for any pointers. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "pyglet-users" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/pyglet-users?hl=en -~----------~----~----~----~------~----~------~--~---
