【问题标题】:Recording Coordinates in Pygame在 Pygame 中记录坐标
【发布时间】:2012-02-15 00:54:12
【问题描述】:

我正在使用 pygame 并且想知道这个: 您按下按钮 X 将图像粘贴到 (x,y) 处的表面上。然后,您将选择器移动到新坐标 (xnew, ynew) 并点击按钮 X 以在 (xnew, ynew) 处对另一个图像进行 blit 如何保存图像被 blitted 的每个坐标以供以后参考?

【问题讨论】:

    标签: python python-3.x pygame


    【解决方案1】:

    只需...将它们添加到列表中?

    blit_spots = []
    
    # ...later on...
    blit_spots.append((x, y))
    

    【讨论】:

    • if (newx, newy) in blit_spots:(尽管如果您想要检查成员资格,您可能希望将blit_spots 改为set 并使用blit_spots.add()
    • 那么在我这样做之后,我怎样才能回去检查坐标呢?例如,按钮 X 在 (x,y) 处对 imageA 进行 blits。如果光标再次位于 (x,y) 处,则按钮 X 会在 (x,y) 处对 imageB 进行 blit,但如果光标不在 (x, y) 处,则按钮 X 会在 imageA 处进行 blit。
    • 没关系,我修好了!使用一个循环,使用列表索引等检查每个坐标。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-03-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多