小编use*_*937的帖子

pygame.mouse.get_pos 和 Rect.collidepoint 的 Python 表面真实位置坐标

在我的 python prog 中,我有 2 个表面:

  • ScreenSurface : 屏幕
  • FootSurface: 另一个表面闪烁ScreenSurface

我在 上放了一些矩形FootSurface,问题是Rect.collidepoint()给了我链接到 的相对坐标FootSurfacepygame.mouse.get_pos()给出了绝对坐标。

例如 :

pygame.mouse.get_pos() --> (177, 500) 与主表面命名相关 ScreenSurface

Rect.collidepoint()--> 与第二个表面有关,FootSurface其中 rect 被 blitted

那么就行不通了。有没有一种优雅的python方式来做这件事:将鼠标的相对位置放在我的FootSurface或绝对位置上Rect;或者必须将我的代码更改分裂RectScreenSurface

python mouse pygame pygame-surface

5
推荐指数
1
解决办法
3129
查看次数

标签 统计

mouse ×1

pygame ×1

pygame-surface ×1

python ×1