如何修复此不推荐警告

2024-03-28 20:10:35 发布

您现在位置:Python中文网/ 问答频道 /正文

DeprecationWarning: an integer is required (got type float). Implicit conversion to integers using int is deprecated, and may be removed in a future version of Python.

win.blit(playerStand, (x, y))

DeprecationWarning: an integer is required (got type float). Implicit conversion to integers using int is deprecated, and may be removed in a future version of Python.

win.blit(walkLeft[animCount // 5], (x, y))


Tags: tointegersanistyperequiredintegerfloat
1条回答
网友
1楼 · 发布于 2024-03-28 20:10:35

警告与^{}的坐标参数有关。浮点坐标意味着^{}的原点在窗口中的到个像素之间。那没什么意义。坐标会自动隐式截断,并由警告指示。
使用^{}^{}将浮点坐标转换为整数:

win.blit(playerStand, (round(x), round(y)))

相关问题 更多 >