3
在鼠標中,當我旋轉身體時,其形狀不旋轉。當我施加衝動時,形狀與預期一致地移動。我的谷歌搜索表明,身體旋轉時身體的形狀應該旋轉。我從根本上誤解輪換?當我旋轉身體時,鼠標身體的形狀不會旋轉
下面是相關輪換代碼:
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)