box2D: B2RayCastCallback class missing


#1

Hello again.
As the title suggests, B2RayCastCallback class is missing from https://github.com/openfl/box2d
I’m following this tutorial: http://www.iforce2d.net/b2dtut/world-querying
and at one point they want me to extend b2RayCastCallback which doesn’t exist.
If anyone experienced with box2d could help me out on how to work around this problem, that would be fantastic.


#2

Hi!

I think we’re using a Haxe function type for the callback, here:

so you could try passing a function like:

function rayCastCallback (fixture:B2Fixture, point:B2Vec2, normal:B2Vec2, fraction:Float):Void {
    ...
}

#3
function rayCastCallback (fixture:B2Fixture, point:B2Vec2, normal:B2Vec2, fraction:Float):Float{
    ...
}

Thanks, just needed to replace the return value from Void to Float.


#4

Oh, yeah! Dynamic, not Void. I wonder if it always returns a Float, or if it ever returns something else?


#5

From all the tutorials I’ve read on this subject it seems like this function should return Float.
http://www.iforce2d.net/b2dtut/world-querying
http://www.learn-cocos2d.com/api-ref/1.0/Box2D/html/classb2_ray_cast_callback.html
and on page 60 of the official manual for box2D:
http://box2d.org/manual.pdf
And I think if you return some other class, it will be registered as returning 1, which is the best option for the function to work properly.

Again, thanks a lot of the help.