Thanks for the comments guys. One use case of many Sprites sharing the exact animatinos would be things like water, or quicksand sprites in a Tiled game. I see your point though, and I agree that the actual control of the Animations is the important thing. My thought was that the Animation class could be subclassed easily.
If not reusing animations, there would indeed be some additional overhead from the extra event handling. It seemed negligible in my tests, but.... I did not consider the resource module caching(!). Thanks for pointing that out. In fact, it does return exactly the same Animation instance. I will need to make a slight tweak, and run some more benchmarks. Instead of returning the cached Animation instance, we can just return a new Animation instance that contains the existing Frames (textures) from the cached Animation. Your idea of an Animator is interesting. It would essentially replace what the existing Sprite._animate method does. Slightly tweaking the pyglet.resource caching would prevent wasted Textures, but the animation frame updates need to happen somewhere. This might be a good solution. However, the issue of frame update scheduling needs to happen somewhere. If it's happening inside an Animator class, then the Sprite needs to be informed of the update so that it can update it's texture/tex_coords. On Tuesday, May 29, 2018 at 5:24:20 PM UTC+9, Daniel Gillet wrote: > > Correction to my previous example. Trying to re-load the animation with > pyglet.resource.animation (and not Pygame!!!) would not work as the > Animation is cached and we would get the same object. So users will wonder > how to copy it and I think this is not the way to go. :) > -- 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.
