void EnableDebugMode() { CCBox2dDraw debugDraw = new CCBox2dDraw("fonts/arial-12"); world.SetDebugDraw(debugDraw); debugDraw.AppendFlags(b2DrawFlags.e_shapeBit); }
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); }
// This method should undo anything that was done by the loadWorld and afterLoadProcessing // methods, and return to a state where loadWorld can safely be called again. public virtual void Clear() { if (m_world != null) { Console.WriteLine("Deleting Box2D world"); m_world = null; } if (m_debugDraw != null) m_debugDraw = null; if (m_touch != null) m_touch.clear(); }
/// <summary> /// Attempts to load the world from the .json file given by getFilename. /// If successful, the method afterLoadProcessing will also be called, /// to allow subclasses to do something extra while the b2dJson information /// is still available. /// </summary> private void LoadWorld() { Clear(); m_debugDraw = new CCBox2dDraw(DEFAULT_FONT); m_debugDraw.AppendFlags(b2DrawFlags.e_shapeBit | b2DrawFlags.e_aabbBit | b2DrawFlags.e_centerOfMassBit | b2DrawFlags.e_jointBit | b2DrawFlags.e_pairBit); string fullpath = GetFilename(); Console.WriteLine("Full path is: %s", fullpath); Nb2dJson json = new Nb2dJson(); StringBuilder tmp = new StringBuilder(); m_world = json.ReadFromFile(fullpath, tmp); if (m_world != null) { Console.WriteLine("Loaded JSON ok"); m_world.SetDebugDraw(m_debugDraw); b2BodyDef bodyDef = new b2BodyDef(); m_touch = new MouseTouch(m_world, this); m_touch.m_mouseJointGroundBody = m_world.CreateBody(bodyDef); AfterLoadProcessing(json); } else Console.WriteLine(tmp); //if this warning bothers you, turn off "Typecheck calls to printf/scanf" in the project build settings }
void EnableDebugMode() { debugDraw = new CCBox2dDraw("fonts/MarkerFelt-16", Constants.PTM_RATIO); world.SetDebugDraw(debugDraw); debugDraw.AppendFlags(b2DrawFlags.e_shapeBit); }