Box2D不适用于Python

时间:2011-10-19 15:34:50

标签: python box2d traceback

我安装了Python 2.6.6和Box2D 2.0.2b1。并且无法创建box2d世界--b2World()。

简单示例:

import Box2D
Box2D.b2World()

无论我输入函数b2World,我收到此错误:

Traceback (most recent call last):
  File "<pyshell#2>", line 1, in <module>
    Box2D.b2World()
  File "C:\Python26\lib\site-packages\Box2D\Box2D.py", line 4350, in __init__
    _Box2D.b2World_swiginit(self,_Box2D.new_b2World(*args))
TypeError: new_b2World expected 3 arguments, got 0

1 个答案:

答案 0 :(得分:3)

尝试类似:

world = b2World(gravity=(0,-10), doSleep=True)

我查看了2.0.2版本,看起来你应该像这样传递你的论点:

worldAABB=box2d.b2AABB()
worldAABB.lowerBound = (-100.0, -100.0)
worldAABB.upperBound = ( 100.0, 100.0)
gravity = (0.0, -10.0)
world = box2d.b2World(worldAABB, gravity, True)