简体   繁体   English

Pygame会在另一个之上发白吗?

[英]Pygame blit on top of another?

I'm trying to create a game, with pygame, and right now I'm attempting to blit my health bar. 我正在尝试使用pygame创建一个游戏,而现在我正在尝试消除健康状况。 It's apparently there, just under the background image. 很明显,它就在背景图片的下面。 Is there a way to have it blit / drawn on top of the background? 有没有一种方法可以使其在背景上方变白/绘制? I've tried re-arranging the order. 我试过重新安排订单。

screen.blit(healthbar, (5,5))

for health1 in range(healthvalue):
    screen.blit(health, (health1+8,8))

screen.blit(background,(0,0))

Suggestions or am I doing this completely wrong? 建议还是我这样做完全错误?

The order is wrong, and you should update the screen after drawing everything: 顺序错误,绘制所有内容后应更新屏幕:

screen.blit(backround,(0,0))

screen.blit(healthbar, (5,5))

for health1 in range(healthvalue):
    screen.blit(health, (health1+8,8))

...

pygame.display.flip()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM