简体   繁体   中英

Box2D won't work with Python

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

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM