On Sep 2, 2:05 pm, Jonathan Hartley <[email protected]> wrote:
> 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.
Is there any reason to create separate sprites for what are just
different images? If you set the sprite.image to be whatever static
image or animation you like depending on the situation, batch.draw()
will take care of the rest. Or when you say sprites do you mean
images, and not pyglet.sprite.Sprites.
For example, what I'm doing is loading all images and animations
(which are composed from sprite sheets) into an images class and an
animations class. The animations class creates a texture grid from the
sprite sheet and then the animation with a get_animation(), also
transforming it horizontally for the opposite direction. Anyway, then
when the sprite needs a different image I set the sprite.image to what
it needs, either an images.image or an animations.animation.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---