pygame - 在pygame中按下鼠标时制作精灵更改图像
问题描述
当鼠标按下一会儿时,如何让精灵改变它的图像,然后在pygame中恢复正常?我尝试制作一个尝试在短时间内更改图像的命中功能。
这是该功能:
def hit(self, hit_img):
self.image = hit_img
for i in range(300):
self.update()
这是调用者:
if pygame.mouse.get_pressed():
if weapon == "axe.png":
weapon.hit("axe_hit.png")
这是Weapon 类的eq函数:
def __eq__(self, other):
return True if self.image == other else False
但这没有用。我能做些什么呢?
编辑:所以将 [两个下划线]eq[两个下划线] 变成了eq
解决方案
推荐阅读
- powershell - 如果命令响应包含
- java - 如何替换java中字符串列表中整数的第一个实例?
- python - Python:同时使用 os.fork()、os.pipe() 和 subprocess.Popen 问题
- excel - 来自另一个工作表的 VBA IF 命令
- c# - 为什么将 2 个 .NET 框架类相互比较会导致 stackoverflow 异常?
- javascript - firebase.messaging:无法读取未定义的属性“getNotificationPermission_”
- javascript - 我如何在从表单获取用户输入的对象数组中设置状态
- tfs - Team Foundation Server 2018 API 构建定义错误
- java - 打印 kafka 流的内容时出现问题
- vb.net - VB 流阅读器无法正确读取