Fighting game - changing of animations

155 views
Skip to first unread message

Cloud Strife

unread,
Nov 18, 2012, 4:32:10 AM11/18/12
to pyglet-users
I'm creating a fighting game using pyglet, i have two animations:
breathing_set.png, punch_set.png
the first image is for when the character is idle, i need a way so
that once the punch is finished, the characters image should return to
breathing_set.png

Anonymouse

unread,
Nov 18, 2012, 5:40:23 PM11/18/12
to pyglet...@googlegroups.com
You probably want to have all the frames in only one image, then adjust the ranges as needed.



--
You received this message because you are subscribed to the Google Groups "pyglet-users" group.
To post to this group, send email to pyglet...@googlegroups.com.
To unsubscribe from this group, send email to pyglet-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/pyglet-users?hl=en.


Anonymouse

unread,
Nov 19, 2012, 3:47:58 PM11/19/12
to pyglet...@googlegroups.com
It should/might (I'm not sure about the details of using sprites in pyglet) but usually you'd have all the animations in a single spritesheet, where you'd then specify the frame ranges (in a traditional use of sprites in any case. I'm not sure about pyglet).

Also: Please reply to pyglet...@googlegroups.com rather than directly to me.


On 19 November 2012 21:43, Cloud Strife <madar...@gmail.com> wrote:
i already know how to create an animation from a tileset or spriteset
and seting looping to true or false, what i need is how to change the
image once the punch is finished, my idea is:
class Player(pyglet.sprite.Sprite):
    def on_animation_end(self):
        if self.image = self.punch_anim:
            self.image = self.idle_anim

will that work?

Adam Bark

unread,
Mar 25, 2013, 8:37:37 PM3/25/13
to pyglet...@googlegroups.com
On 24/03/13 06:05, Gemedet wrote:
If I can hijack this thread a little:

I tried the example code, and it works just fine when using two animations.  But what if I want the idle pose to just be an AbstractImage?  I'm getting this error after the punch animation plays: "AttributeError: 'NoneType' object has no attribute 'frames'".  I looked in "sprite.py", and I guess it's happening because _animate() finishes executing even if image isn't an Animation anymore.  

self.idle_image = pyglet.image.load(...)

def on_animation_end(self):
    if self.image == self.punch_anim:
        self.image = self.idle_image


Any way to do this?  Thanks!

How about using the pyglet.sprite.Sprite.on_animation_end method to set it? Or do you need to change immediately?
pyglet.image.Animation.from_image_sequence called with a single image with duration of None should give you a static Animation.

Gemedet Go

unread,
Mar 26, 2013, 1:29:44 AM3/26/13
to pyglet...@googlegroups.com
Yeah, I'm using on_animation_end to change them, and it does work if I make an Animation out of the single image.  I just thought it'd be simpler to use the image itself.  Thanks!  That said, the punch animation only works if looping is set to True; if it's set to False, the final frame of the animation doesn't play.

self.punch_anim = Animation.from_image_sequence(..., 1/30.0, False)

Is that how it's supposed to work?


--
You received this message because you are subscribed to a topic in the Google Groups "pyglet-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/pyglet-users/nCSoJ2CGbzo/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to pyglet-users...@googlegroups.com.

To post to this group, send email to pyglet...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages