我的目标是随着时间的推移显示一系列背景,然后我可以显示精灵以创建游戏启动动画,就像原始的口袋妖怪红/蓝一样(视频参考:https://www.youtube.com /watch?v=C19O5xm51dk)
这是我目前的代码。当我一直在寻找解决方案时,我在底部有 2 条评论作为伪代码,但每次我尝试新的东西时,第一张图片不显示,它立即显示第二张图片。
import pygame, sys, time
from pygame import mixer
from pygame.locals import *
pygame.init()
mixer.init()
HEIGHT = 576
WIDTH = 640
FPS = 60
FramePerSec = pygame.time.Clock()
displaysurface = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("Pykemon")
blank_img = pygame.image.load('../Pykemon/Intro and Title Images/blank.png')
blank_img = pygame.transform.scale(blank_img, (640, 576))
copyright_screen_img = pygame.image.load('../Pykemon/Intro and Title Images/copyright screen.png')
copyright_screen_img = pygame.transform.scale(copyright_screen_img, (640, 576))
def background_img(image_name):
displaysurface.blit(image_name, dest)
dest = (0, 0)
while True:
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
displaysurface.fill((255,255,255))
background_img(copyright_screen_img)
# Hold this image for 3 seconds
displaysurface.fill((255, 255, 255))
background_img(blank_img)
# Hold this image for 3 seconds
pygame.display.update()
FramePerSec.tick(FPS)
我曾尝试使用 pygame.time.get_ticks() 创建一个 if 语句,根据传递的 ms 更改图像,但它遇到了同样的问题,只显示第二张图像。