Beispiel #1
0
		public static Test CreateRubeTestFile()
		{ 
			Console.WriteLine(GuiDemo.CurrentRubeFile);
			StringBuilder errorMsg = new StringBuilder();
			Nb2dJson json = new Nb2dJson();
			World world = json.ReadFromFile(GuiDemo.CurrentRubeFile, errorMsg);
			
			var theName = "ball";
			var res = json.GetBodiesByName(theName);
			Console.WriteLine(res);
			
			return new RubeTestFile(world);
		}
Beispiel #2
0
        public void SetJson(string fullpath)
        {
            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_groundBody = m_world.CreateBody(bodyDef);
            }
            else
                Console.WriteLine(tmp); //if this warning bothers you, turn off "Typecheck calls to printf/scanf" in the project build settings

        }
Beispiel #3
0
		void HandleClicked (object sender, EventArgs e)
		{
			var button = sender as Button;

			if (button.Tag.ToString() == "load")
			{
				using (System.Windows.Forms.OpenFileDialog op = new System.Windows.Forms.OpenFileDialog())
				{
					op.ShowDialog();
					if (op.FileName.EndsWith(".json"))
					{
						CurrentRubeFile = op.FileName;
						_game.StarTestRube();
					}
				}
			}


            if (button.Tag.ToString() == "dump")
            {
                System.Windows.Forms.SaveFileDialog op = new System.Windows.Forms.SaveFileDialog();
                //op.FileName = @"C:\Users\ivan\Desktop\t1.json";
                op.ShowDialog();
                if (op.FileName.EndsWith(".json"))
                {
                    StringBuilder errorMsg = new StringBuilder();
                    Nb2dJson json = new Nb2dJson();
                    if (!json.WriteToFile(FarseerPhysics.TestBed.Framework.Test.World, op.FileName, 4, errorMsg))// 4-space
                        Console.WriteLine(errorMsg);
                }
            }


		}