微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

使用 vector2 时,我在 pygame 中遇到错误

如何解决使用 vector2 时,我在 pygame 中遇到错误

我得到一个

不支持 += 的操作数类型:'nonetype' 和 'pygame.math.Vector2'

运行以下代码

#tab-button {
  display: table;
  table-layout: fixed;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  list-style: none;
}

#tab-button li a {
  display: block;
  padding: 0.5em;
  background: #95a5a6;
  text-align: center;
  color: #000;
  text-decoration: none;
  height: 100%;
}

错误在第 15 行

解决方法

方法 return 中缺少 Player.get_pix_pos 语句:

class Player:
    # [...]

    def get_pix_pos (self):
        return vec((self.grid_pos.x*self.app.cell_width)+TOP_BOTTOM_BUFFER//2+self.app.cell_width//2,(self.grid_pos.y*self.app.cell_height)+TOP_BOTTOM_BUFFER//2+self.app.cell_height//2)

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。