app2图像应该从右侧滑入,但它没有滑入。两个图像都是1920x1080。我怎样才能解决这个问题?你知道吗
import pygame, sys
from pygame.locals import*
number=1
screen = pygame.display.set_mode((1920,1080))
app1=pygame.image.load("app1.jpg").convert()
app2=pygame.image.load("app2.jpg").convert()
clock = pygame.time.Clock()
app1x=0
app2x=1920
loop=True
while loop:
screen.fill( (0,0,0) )
for event in pygame.event.get():
if event.type==KEYDOWN:
if event.key==K_RIGHT:
print ("right")
number=number+1
if event.type==pygame.QUIT:
print("l")
loop=False
pygame.quit()
quit()
screen.blit(app1, (app1x,0))
if number==1:
screen.blit(app1, (app1x,0))
if number==2:
if app2x==0:
print ("d")
else:
app2x=app2x-1
app1x=app1x-1
clock.tick(20)
pygame.display.update()
您只更新屏幕的一部分,而时钟不在while循环内。下面是使用您的代码的示例:
另外,请注意我是如何在整个
while
循环之后移动pygame.quit()
。当loop
为false并结束时,pygame也将退出。移动pygame.quit()
只是稍微清理一下代码,并不会显著影响代码。你知道吗干杯!你知道吗
相关问题 更多 >
编程相关推荐