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; } }
/// <summary> /// Query the world for all fixtures that potentially overlap the provided AABB. /// </summary> /// <param name="callback">a user implemented callback class.</param> /// <param name="aabb">the query box.</param> public virtual void queryAABB(QueryCallback callback, AABB aabb) { wqwrapper.broadPhase = m_contactManager.m_broadPhase; wqwrapper.callback = callback; m_contactManager.m_broadPhase.query(wqwrapper, aabb); }
public b2Fixture getTouchedFixture(CCTouch touch) { CCPoint screenPos = touch.Location; b2Vec2 worldPos = ScreenToWorld(screenPos); // Make a small box around the touched point to query for overlapping fixtures b2AABB aabb; b2Vec2 d = new b2Vec2(0.001f, 0.001f); aabb.LowerBound = worldPos - d; aabb.UpperBound = worldPos + d; QueryCallback callback = new QueryCallback(worldPos); m_world.QueryAABB(callback, aabb); return callback.m_fixture; }