[英]I don't understand why i can't get readline function in python to work in this program. What am I doing wrong?
[英]I can't get QueryAABB to work in PyBox2D. What am I doing wrong?
我正在嘗試檢測鼠標指針是否在主體上,因此我可以將其拖動,但是出現以下錯誤。 我不知道是我還是pybox2d中的錯誤,但我已經呆了好幾個小時了,文檔還是很古老的。
>>> 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(未檢測到任何形狀,請繼續查找),因為我尚未為主體創建形狀,但這不能解釋類型錯誤。 請幫助,在此先感謝!
愚蠢的我,我明白了。 就在“古代”文檔中。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.