Hi,
I am searching for box2d examples in openfl, please add some if available.
I also have tried myself to convert as3 examples to openfl and pretty much close in completing rackdoll example, only one problem is left i.e.
Unable to convert B2Joint to B2MouseJoint
public var m_mouseJoint = null;
//======================
// Mouse Drag
//======================
public function MouseDrag():Void{
// mouse press
if (Input.mouseDown && m_mouseJoint==null){
var body:B2Body = GetBodyAtMouse();
if (body!=null)
{
var md:B2MouseJointDef = new B2MouseJointDef();
md.bodyA = Global.world.getGroundBody();
md.bodyB = body;
md.target.set(mouseXWorldPhys, mouseYWorldPhys);
md.collideConnected = true;
md.maxForce = 300.0 * body.getMass();
//var md1:B2MouseJointDef = new B2MouseJointDef();
m_mouseJoint = Global.world.createJoint(md);// cast b2MouseJoint;
trace("Creating joint");
body.setAwake(true);
}
}
// mouse release
if (!Input.mouseDown){
if (m_mouseJoint!=null)
{
Global.world.destroyJoint(m_mouseJoint);
m_mouseJoint = null;
}
}
// mouse move
if (m_mouseJoint!=null)
{
var p2:B2Vec2 = new B2Vec2(mouseXWorldPhys, mouseYWorldPhys);
//m_mouseJoint = cast B2MouseJoint;
m_mouseJoint.setTarget(p2);
}
}
Above function successfully hang the body on touch/clicking if I comment out the last line “m_mouseJoint.setTarget(p2);” but do not drag the body, uncommenting the line throws error B2Joint has no field setTarget.
AS3 use “as” keyword to convert b2joint to b2mousejoint, how can I achieve same using Haxe Openfl
Thanks in advance