Why does Animation not have set_anchor()?

74 views
Skip to first unread message

Sam Henderson

unread,
Nov 26, 2019, 2:54:18 PM11/26/19
to pyglet-users
Hey everyone, learning lots developing functions and code for a game I'm making using pyglet. First posting in this email group and I am genuinely curious as to the answer for this question. Not sure if the solution has not been implemented because no-one has got around to doing so, or if there are technical/efficiency reasons for leaving it out. I will gladly help to start expanding pyglet on github but think I need a question like this answered for I tackle that.

Issue: I want to change the anchor point of an entire pyglet.animation. Right now I have a separate function created to do this (see below). Can this function be added to pyglet.image.Animation so that anyone else looking for this solution just has to called set_anchor ? Obviously the format of the function can be cleaned up.


def set_anchor(self, anim: pyglet.image.Animation, anchor_x=0, anchor_y=0):
"""Set anchor points for animation. Anchor point is set for each individual frame image."""
for f in anim.frames:
f.image.anchor_x = anchor_x
f.image.anchor_y = anchor_y




Thank you,
Sam Henderson

Charles M

unread,
Nov 26, 2019, 5:39:19 PM11/26/19
to pyglet-users
Hello!

I wouldn't say the solution is not implemented, or omitted for any performance reasons. It was probably just expected that the user would solve it in the way you did it. However, I agree that adding helper functions could still be useful and probably worth a PR. 

Such a function should probably be added to ImageGrids as well, since it also handles a group of images.

Also the Discord is more active than this group, so it might be easier to ask questions there in the future. :)
Reply all
Reply to author
Forward
0 new messages