//--------------- Internals Below ------------------- static public b2Joint Create(b2JointDef def, object allocator) { b2Joint joint = null; if (def.type == e_distanceJoint) { //void* mem = allocator->Allocate(sizeof(b2DistanceJoint)); joint = new b2DistanceJoint(def as b2DistanceJointDef); } else if (def.type == e_mouseJoint) { //void* mem = allocator->Allocate(sizeof(b2MouseJoint)); joint = new b2MouseJoint(def as b2MouseJointDef); } else if (def.type == e_prismaticJoint) { //void* mem = allocator->Allocate(sizeof(b2PrismaticJoint)); joint = new b2PrismaticJoint(def as b2PrismaticJointDef); } else if (def.type == e_revoluteJoint) { //void* mem = allocator->Allocate(sizeof(b2RevoluteJoint)); joint = new b2RevoluteJoint(def as b2RevoluteJointDef); } else if (def.type == e_pulleyJoint) { //void* mem = allocator->Allocate(sizeof(b2PulleyJoint)); joint = new b2PulleyJoint(def as b2PulleyJointDef); } else if (def.type == e_gearJoint) { //void* mem = allocator->Allocate(sizeof(b2GearJoint)); joint = new b2GearJoint(def as b2GearJointDef); } else if (def.type == e_lineJoint) { //void* mem = allocator->Allocate(sizeof(b2LineJoint)); joint = new b2LineJoint(def as b2LineJointDef); } else if (def.type == e_weldJoint) { //void* mem = allocator->Allocate(sizeof(b2WeldJoint)); joint = new b2WeldJoint(def as b2WeldJointDef); } else if (def.type == e_frictionJoint) { //void* mem = allocator->Allocate(sizeof(b2FrictionJoint)); joint = new b2FrictionJoint(def as b2FrictionJointDef); } else if (def.type == e_ropeJoint) { joint = new b2RopeJoint(def as b2RopeJointDef); } else { //b2Settings.b2Assert(false); } return(joint); }
public virtual bool MouseDown(b2Vec2 p) { m_mouseWorld = p; if (m_mouseJoint != null) { return false; } // Make a small box. b2AABB aabb = new b2AABB(); b2Vec2 d = new b2Vec2(); d.Set(0.001f, 0.001f); aabb.LowerBound = p - d; aabb.UpperBound = p + d; // Query the world for overlapping shapes. QueryCallback callback = new QueryCallback(p); m_world.QueryAABB(callback, aabb); if (callback.m_fixture != null) { b2Body body = callback.m_fixture.Body; b2MouseJointDef md = new b2MouseJointDef(); md.BodyA = m_groundBody; md.BodyB = body; md.target = p; md.maxForce = 1000.0f * body.Mass; m_mouseJoint = (b2MouseJoint)m_world.CreateJoint(md); body.SetAwake(true); return true; } else { //Como no ha encontrado un objeto empezamos el arrastre IsArrastring = true; originPosition = new CCPoint(p.x, p.y); return true; } }
public void clear() { m_mouseJoint = null; m_mouseJointGroundBody = null; }
public virtual void MouseUp(b2Vec2 p) { if (IsArrastring) { //parent.Position = null; IsArrastring = false; } else { if (m_mouseJoint != null) { m_world.DestroyJoint(m_mouseJoint); m_mouseJoint = null; } } }
public virtual void MouseUp(b2Vec2 p) { if (m_mouseJoint != null) { m_world.DestroyJoint(m_mouseJoint); m_mouseJoint = null; } if (m_bombSpawning) { CompleteBombSpawn(p); } }
public virtual bool MouseDown(b2Vec2 p) { m_mouseWorld = p; if (m_mouseJoint != null) { return false; } // Make a small box. b2AABB aabb = new b2AABB(); b2Vec2 d = new b2Vec2(); d.Set(0.001f, 0.001f); aabb.LowerBound = p - d; aabb.UpperBound = p + d; // Query the world for overlapping shapes. QueryCallback callback = new QueryCallback(p); m_world.QueryAABB(callback, aabb); if (callback.m_fixture != null) { b2Body body = callback.m_fixture.Body; b2MouseJointDef md = new b2MouseJointDef(); md.BodyA = m_groundBody; md.BodyB = body; md.target = p; md.maxForce = 1000.0f * body.Mass; m_mouseJoint = (b2MouseJoint) m_world.CreateJoint(md); body.SetAwake(true); return true; } return false; }
public Test() { m_destructionListener = new DestructionListener(); m_debugDraw = new CCBox2dDraw("fonts/arial-12", 1); b2Vec2 gravity = new b2Vec2(); gravity.Set(0.0f, -10.0f); m_world = new b2World(gravity); m_bomb = null; m_textLine = 30; m_mouseJoint = null; m_pointCount = 0; m_destructionListener.test = this; m_world.SetDestructionListener(m_destructionListener); m_world.SetContactListener(this); m_world.SetDebugDraw(m_debugDraw); m_world.SetContinuousPhysics(true); m_world.SetWarmStarting(true); m_bombSpawning = false; m_stepCount = 0; b2BodyDef bodyDef = new b2BodyDef(); m_groundBody = m_world.CreateBody(bodyDef); }
public static b2Joint Create(b2JointDef def) { b2Joint joint = null; switch (def.JointType) { case b2JointType.e_distanceJoint: { joint = new b2DistanceJoint((b2DistanceJointDef)def); } break; case b2JointType.e_mouseJoint: { joint = new b2MouseJoint((b2MouseJointDef)def); } break; case b2JointType.e_prismaticJoint: { joint = new b2PrismaticJoint((b2PrismaticJointDef)def); } break; case b2JointType.e_revoluteJoint: { joint = new b2RevoluteJoint((b2RevoluteJointDef)def); } break; case b2JointType.e_pulleyJoint: { joint = new b2PulleyJoint((b2PulleyJointDef)def); } break; case b2JointType.e_gearJoint: { joint = new b2GearJoint((b2GearJointDef)def); } break; case b2JointType.e_wheelJoint: { joint = new b2WheelJoint((b2WheelJointDef)def); } break; case b2JointType.e_weldJoint: { joint = new b2WeldJoint((b2WeldJointDef)def); } break; case b2JointType.e_frictionJoint: { joint = new b2FrictionJoint((b2FrictionJointDef)def); } break; case b2JointType.e_ropeJoint: { joint = new b2RopeJoint((b2RopeJointDef)def); } break; default: Debug.Assert(false); break; } return joint; }
public static b2Joint Create(b2JointDef def) { b2Joint joint = null; switch (def.JointType) { case b2JointType.e_distanceJoint: { joint = new b2DistanceJoint((b2DistanceJointDef)def); } break; case b2JointType.e_mouseJoint: { joint = new b2MouseJoint((b2MouseJointDef)def); } break; case b2JointType.e_prismaticJoint: { joint = new b2PrismaticJoint((b2PrismaticJointDef)def); } break; case b2JointType.e_revoluteJoint: { joint = new b2RevoluteJoint((b2RevoluteJointDef)def); } break; case b2JointType.e_pulleyJoint: { joint = new b2PulleyJoint((b2PulleyJointDef)def); } break; case b2JointType.e_gearJoint: { joint = new b2GearJoint((b2GearJointDef)def); } break; case b2JointType.e_wheelJoint: { joint = new b2WheelJoint((b2WheelJointDef)def); } break; case b2JointType.e_weldJoint: { joint = new b2WeldJoint((b2WeldJointDef)def); } break; case b2JointType.e_frictionJoint: { joint = new b2FrictionJoint((b2FrictionJointDef)def); } break; case b2JointType.e_ropeJoint: { joint = new b2RopeJoint((b2RopeJointDef)def); } break; default: Debug.Assert(false); break; } return(joint); }