有什么办法可以“清除"垃圾邮件吗?表面? [英] Is there any way to "clear" a surface?

查看:128
本文介绍了有什么办法可以“清除"垃圾邮件吗?表面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么方法可以清除已被污渍覆盖的表面吗?

Is there any way to clear a surface from anything that has been blitted to it?

推荐答案

如果要使pygame Surface对象干净",则擦除所有被涂抹过的图像,并在每次游戏循环中为其涂抹新图像并保持对等像素的Alpha值而不创建新的表面,您可以填充它,但是要使用纯色而不是纯色

If what you want is to make a pygame Surface object "clean", that is erase all images blited to it, to blit new images to it every game loop and keep the peer pixel alpha without creating a new surface, you can fill it, but instead of a solid color, use a transparent color

from pygame import Color, Surface
empty = Color(0,0,0,0) #The last 0 indicates 0 alpha, a transparent color
field = Surface((width, height), flags=SRCALPHA)

#Inside the game loop
field.fill(empty)

*抱歉,我的英语不好,还在学习中

*Sorry is my english is bad, still learning

这篇关于有什么办法可以“清除"垃圾邮件吗?表面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆