Joined: 8/22/2011(UTC) Posts: 170 Location: Moscow
Thanks: 3 times Was thanked: 2 time(s) in 2 post(s)
|
I understand how to solve the problem. Thanks for the tips and help
Hi. I can not understand the scenes and Screens. Let's look at public static void OpenTwoNormalScreens() test
Code:#region OpenTwoNormalScreens (LongRunning)
/// <summary>
/// Open two normal screens
/// </summary>
[Test, Category("Visual")]
public static void OpenTwoNormalScreens()
{
// Create and open a normal screen(with starting a new scene)
Screen firstScreen = new Screen("<FirstScreen>");
firstScreen.Add(new Label
{
Name = "FirstScreenLabel",
LocalArea = Rectangle.FromCenter(0.5f, 0.45f, 0.2f, 0.05f),
Text = "First screen",
});
firstScreen.Open();
// and open another one per 'Space' key
Screen secondScreen = null;
// Start the application
Application.Start(delegate
{
// and let close the overlay scene by the space key
// -> the scene shouldn't crash anymore if any e.g. mouse input is done
if (Input.Keyboard.SpaceReleased)
{
// First time open the second screen now
if (secondScreen == null)
{
secondScreen = new Screen("<SecondScreen>");
secondScreen.Add(new Label
{
Name = "SecondScreenLabel",
LocalArea = Rectangle.FromCenter(0.5f, 0.55f, 0.2f, 0.05f),
Text = "Second screen",
});
secondScreen.Open();
} // if
// and close it on the second time again
else
{
secondScreen.Close();
secondScreen = null;
} // else
} // if
});
}
#endregion
Work,but.... Little change, and monitor the memory
Code: #region OpenTwoNormalScreens (LongRunning)
/// <summary>
/// Open two normal screens
/// </summary>
[Test, Category("Visual")]
public static void OpenTwoNormalScreens()
{
// Create and open a normal screen(with starting a new scene)
Screen firstScreen = new Screen("<FirstScreen>");
firstScreen.Add(new Label
{
Name = "FirstScreenLabel",
LocalArea = Rectangle.FromCenter(0.5f, 0.45f, 0.2f, 0.05f),
Text = "First screen",
});
firstScreen.Open();
// and open another one per 'Space' key
Screen secondScreen = null;
// Start the application
Application.Start(delegate
{
// and let close the overlay scene by the space key
// -> the scene shouldn't crash anymore if any e.g. mouse input is done
// First time open the second screen now
if (secondScreen == null)
{
secondScreen = new Screen("<SecondScreen>");
secondScreen.Add(new Label
{
Name = "SecondScreenLabel",
LocalArea = Rectangle.FromCenter(0.5f, 0.55f, 0.2f, 0.05f),
Text = "Second screen",
});
secondScreen.Open();
} // if
// and close it on the second time again
else
{
secondScreen.Close();
secondScreen = null;
} // else
// if
});
}
#endregion
Memory leak...I tried to use Screen, Scenes,Scene.Open(...), and other,But the true result is not found... How to close or open a ui screen in scene correctly.
Code:using Delta.Engine;
using Delta.Engine.Dynamic;
using Delta.Rendering.Basics.Materials;
using Delta.Scenes;
using Delta.Scenes.UserInterfaces;
using Delta.Utilities.Datatypes;
namespace TD
{
internal class Test : DynamicModule
{
public Screen ExitScreen;
public Screen FreeScreen;
public Scene MainScene;
public Screen MainScreen;
public bool Testbool = true;
public Test() : base("Test", typeof (Application))
{
FreeScreen = new Screen("<FreeScreen>", false)
{
Background = new Material2DColored(Color.White),
};
MainScreen = new Screen("<MainScreen>", false)
{
Background = new Material2DColored(Color.Red),
};
ExitScreen = new Screen("<ExitScreen>", false)
{
Background = new Material2DColored(Color.Gold),
};
MainScene = Scene.Open(FreeScreen);
MainScene.Add(MainScreen);
MainScene.Add(ExitScreen);
}
public override void Run()
{
if (Testbool)
{
//need open Main Screen
}
else
{
//need open Exit Screen
}
}
}
}
Edited by user Saturday, January 7, 2012 2:12:36 PM(UTC)
| Reason: Not specified |
Russian game developer. Давайте делать игры в команде. Идет набор. |