public Test() { m_destructionListener = new DestructionListener(); m_debugDraw = new CCBox2dDraw("fonts/arial-12"); 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 virtual void Step(Settings settings) { float timeStep = settings.hz > 0.0f ? 1.0f / settings.hz : 0.0f; if (settings.pause) { if (settings.singleStep) { settings.singleStep = false; } else { timeStep = 0.0f; } m_debugDraw.DrawString(5, m_textLine, "****PAUSED****"); m_textLine += 15; } b2DrawFlags flags = 0; if (settings.drawShapes) { flags |= b2DrawFlags.e_shapeBit; } if (settings.drawJoints) { flags |= b2DrawFlags.e_jointBit; } if (settings.drawAABBs) { flags |= b2DrawFlags.e_aabbBit; } if (settings.drawPairs) { flags |= b2DrawFlags.e_pairBit; } if (settings.drawCOMs) { flags |= b2DrawFlags.e_centerOfMassBit; } m_debugDraw.SetFlags(flags); m_world.SetWarmStarting(settings.enableWarmStarting > 0); m_world.SetContinuousPhysics(settings.enableContinuous > 0); m_world.SetSubStepping(settings.enableSubStepping > 0); m_pointCount = 0; m_world.Step(timeStep, settings.velocityIterations, settings.positionIterations); if (timeStep > 0.0f) { ++m_stepCount; } }
public Mouse() { //m_destructionListener = new DestructionListener(); m_debugDraw = new CCBox2dDraw("fonts/arial-16"); b2Vec2 gravity = new b2Vec2(); gravity.Set(500, 500); m_world = new b2World(gravity); m_world.SetAllowSleeping(false); m_world.SetContinuousPhysics(true); m_world.SetDebugDraw(m_debugDraw); m_debugDraw.AppendFlags(b2DrawFlags.e_shapeBit | b2DrawFlags.e_aabbBit | b2DrawFlags.e_centerOfMassBit | b2DrawFlags.e_jointBit | b2DrawFlags.e_pairBit); m_world.SetContinuousPhysics(true); m_world.SetWarmStarting(true); }