在 Pymunk 中,当我旋转一个物体时,它的形状并没有旋转。当我施加脉冲时,形状会像预期的那样同步移动。我的谷歌搜索表明当身体旋转时,身体的形状应该是旋转的。我从根本上误解了轮换吗?
这是相关的轮换代码:
def selectEntity(self, location):
shapes = self.space.point_query(location)
bodies = set()
for shape in shapes:
bodies.add(shape.body)
for body in bodies:
body.angle += 1.57079633 # + 90 degrees
下面是初始化代码:
def _addShip(self, mass, center, angle = 0.):
radius = 10
groupId = self.getNextBodyId() # shapes in the same group do not generate collisions
body = pymunk.Body(mass, pymunk.moment_for_circle(mass, radius / 10, radius)) # mass, inner radius, outer radius, offset
body.angle = angle
partOne = pymunk.Circle(body, radius, center)
partOne.group = groupId
partOne.color = THECOLORS['blue']
partOne.friction = .8
partTwo = pymunk.Circle(body, radius, (center[0], center[1] + 20))
partTwo.group = groupId
partTwo.color = THECOLORS['blue']
partTwo.friction = .8
ship = (partOne, partTwo, body)
self.space.add(*ship)