我做了一个精灵,我想放慢动画,因为这是我所做的
for some reason its slowing my whole game frame to 1o in the class I set the frame by fp = 10 VIDeo
class snow:
def __init__(self,x,y,height,width,color):
self.x = x
self.y = y
self.height = height
self.width = width
self.color = color
self.fp = 10
self.clock = pygame.time.Clock()
self.games = [
pygame.image.load("key1.png"),
pygame.image.load("key2.png"),
pygame.image.load("key3.png"),
pygame.image.load("key4.png"),
pygame.image.load("key5.png"),
pygame.image.load("key6.png"),
pygame.image.load("key7.png")]
self.anim_index = 0
self.rect = pygame.Rect(x,y,height,width)
self.direction = "idk"
def draw(self):
self.rect.topleft = (self.x,self.y)
if self.direction == "idk":
window.blit(self.games[self.anim_index],self.rect)
self.clock.tick(self.fp)
self.anim_index += 1
if self.anim_index == len(self.games):
self.anim_index = 0
You should use
pygame.time.get_ticks()
to get current time and calculate when you should change image然后使用
或多或少: