我试图检测鼠标指针是否在一个物体上,以便我可以拖动它,但我得到下面的错误。我不知道是我还是pybox2d中的一个bug,但我已经做了几个小时了,而且这些文档都很古老
>>> from Box2D.b2 import *
>>> w = world()
>>> my_body = w.CreateDynamicBody(position=(1,1))
>>> aabb = AABB()
>>> aabb.lowerBound = (1-.001,1-.001)
>>> aabb.upperBound = (1+.001,1+.001)
>>> def callback(fixture):
... shape = fixture.shape
... p = (1,1)
... if fixture.body.type != 0: # type 0 is static
... if shape.TestPoint(fixture.body.transform,p):
... return False
... return True
...
>>> w.QueryAABB(callback,aabb)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: in method 'b2World_QueryAABB', argument 2 of type 'b2QueryCallback *'
显然,我希望查询返回True(没有检测到形状,请继续查找),因为我还没有为主体创建形状,但这并不能解释类型错误。请帮忙,提前谢谢
我真傻,我想出来了。就在“古代”文件里
https://github.com/pybox2d/pybox2d/wiki/manual#aabb-queries
相关问题 更多 >
编程相关推荐