I'm making my first game with python so I'm confused when to use what technique.
I've got an animation of a running character in several files. From
those files I create an animation and use it to let my character walk.
So far so good. But when my character is moving faster I want the
sprite also to loop faster. I made a updateSprite method, but is
obviously *very* slow.
So how can I update the speed of my character animation, without
building a whole new sprite?
Thanks.
Niels.
def __init__(self):
sprite_speed = 10.0/self.speed # the character speed vs how
fast the sprite should loop
self.images = [
pyglet.image.load('data/images/character/right-1.png'),
pyglet.image.load('data/images/character/right-2.png'),
pyglet.image.load('data/images/character/right-3.png'),
pyglet.image.load('data/images/character/right-4.png'),
pyglet.image.load('data/images/character/right-5.png'),
pyglet.image.load('data/images/character/right-6.png'),
pyglet.image.load('data/images/character/right-7.png'),
pyglet.image.load('data/images/character/right-8.png')
]
self.animation_right =
pyglet.image.Animation.from_image_sequence(self.images, sprite_speed)
self.sprite = pyglet.sprite.Sprite(self.animation_right)
def updateSprite(self):
sprite_speed = 10.0/self.speed # the character speed vs how
fast the sprite should loop
self.animation_right =
pyglet.image.Animation.from_image_sequence(self.images, sprite_speed)
self.sprite = pyglet.sprite.Sprite(self.animation_right)
self.sprite.x = self.x
self.sprite.y = self.y
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---