Question

I have installed Python 2.6.6 and Box2D 2.0.2b1. And can't create box2d world - b2World().

Simple example:

import Box2D
Box2D.b2World()

No matter what I type into function b2World, I received this error:

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
Was it helpful?

Solution

Try something like:

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

I had a look at the 2.0.2 version and it looks like you should pass your arguments like this:

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)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top