0
所以,如果任何人已經使用pyganim來顯示精靈表動畫,並可以告訴我爲什麼我的代碼不顯示動畫,我會感謝你加載。我試着移動座標並改變填充顏色。沒有任何工作,我沒有收到任何錯誤,所以我不知道是什麼問題。使用pyganim的Sprite表單動畫,爲什麼我的Sprite不顯示?
import pygame
from pygame.locals import *
import time
import random
import pyganim
import sys
import os
rects = [(0, 154, 94, 77),
(94, 154, 94, 77),
(188, 154, 94, 77),
(282, 154, 94, 77),
(376, 154, 94, 77),
(470, 154, 94, 77),
(564, 154, 94, 77),
(658, 154, 94, 77),]
file_name = ('explosion1.png')
images = pyganim.getImagesFromSpriteSheet(file_name, rects = rects)
frames = list (zip(images, [100] * len(images)))
animObj = pyganim.PygAnimation(frames)
animObj.play()
white = (255, 255, 255)
black = (0, 0, 0)
pygame.init()
display_width = 800
display_height = 600
gameDisplay = pygame.display.set_mode((display_width, display_height))
pygame.display.set_caption('sprite animations')
clock = pygame.time.Clock()
def game_loop():
gameDisplay.fill(black)
gameExit = False
while not gameExit:
for event in pygame.event.get():
if event.type == pygame.QUIT:
gameExit = True
animObj.blit(gameDisplay,(100, 50))
pygame.display.update()
clock.tick(15)
game_loop()
pygame.quit()
quit()
你打電話給pygame.display.flip()嗎? –
好吧,所以我改變了精靈表,它仍然相當混亂,因爲兩張表之間的寬度和高度等不一樣,但是現在這讓我想知道爲什麼我的第一個表格不工作或者根本不顯示,而是新的是。 – Feline
調用了pygame.display.update(),如果我錯了,那麼糾正我是同一件事。 – Feline