制作暂停画面 [英] Making a pause screen
本文介绍了制作暂停画面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试制作暂停屏幕功能,但图像快门并出现延迟很好.任何想法 这是我的代码:
Im trying to make a pause screen function but the images shutter and appear with a good delay. Any ideas Heres my code:
PauseLogo = pg.image.load('Stop.png')
Pause = pg.image.load('Pause.png')
#------------------------------------------
while running:
clock.tick(FPS)
for event in pg.event.get():
if event.type == pg.QUIT:
running = False
if event.type == pg.KEYDOWN:
if event.key == pg.K_SPACE:
paused = not paused
if paused == True:
clock.tick(27)
screen.blit(PauseLogo, (0,0))
screen.blit(Pause, (400, 330))
if not paused:
all_sprites.update()
screen.fill(DARKGRAY)
all_sprites.draw(screen)
推荐答案
根据paused
的状态绘制不同的场景:
Draw different scenes dependent on the state of paused
:
while running:
clock.tick(FPS)
for event in pg.event.get():
if event.type == pg.QUIT:
running = False
if event.type == pg.KEYDOWN:
if event.key == pg.K_SPACE:
paused = not paused
if paused == True:
screen.blit(PauseLogo, (0,0))
screen.blit(Pause, (400, 330))
else:
all_sprites.update()
screen.fill(DARKGRAY)
all_sprites.draw(screen)
pygame.display.update()
注意,pygame.time.Clock.tick()
测量自上次调用此函数以来的时间并延迟应用程序.如果在应用中调用两次,应用会延迟两次.
Note, pygame.time.Clock.tick()
measures the time since the last call of this function and delays the application. If you call it twice in the application, the application is delayed twice.
这篇关于制作暂停画面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文