XNA 게임에서 사용자 정의 화면이나 팝업 (모달)을 열 수 있습니까? 사용자는 몇 가지 옵션을 표시 할 수 있습니다. 게임 및 앱 세트의 일부가 될 다른 앱.XNA Game - 게임을 시작하기 전에 팝업 또는 사용자 정의 게임 화면 열기
public class MyGame : Game
{
#region Initialization
/// <summary>
/// Creates a new instance of the game.
/// </summary>
public MyGame()
{
graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
///etc;
}
/// <summary>
/// Performs initializations required by the game.
/// </summary>
protected override void Initialize()
{
///I would Like to open a new screen before the actual game
/// menu is displayed ... also return to this screen after the logic is run
/// in that screen
base.Initialize();
}
}
모든 아이디어/제안/샘플. 감사드립니다.
krz.
감사 Blau.I 난 그냥 빈 화면이 표시됩니다,하는 일없이 DrawableGameComponent의 (문서에서 코드를 복사) 솔루션하지만 vain.No에 시도. 게임 생성자에서
나는 조건을 넣어 showScreen가 flase 경우 다음 실행되도록 나는 또한 게임 초기화에 조건을 넣어
if (showScreen)
{
LaunchScreen launcher = new LaunchScreen(this, null);
//Components.Add(launcher);
launcher.Show();
}
else{///constructor code}
으로 메서드를 호출합니다. (확실하지의 경우 적절한 방법을)
클래스를 할 것은 다음과 같습니다
public class LaunchScreen : DrawableGameComponent
{
private Texture2D backgroundImage = null;
private SpriteBatch spriteBatch = null;
public LaunchScreen(Game game, Texture2D texture)
: base(game)
{
backgroundImage = texture;
Visible = false;
Enabled = false;
}
public virtual void Show()
{
Visible = true;
Enabled = true;
}
public virtual void Hide()
{
Visible = false;
Enabled = false;
}
public override void Initialize()
{
base.Initialize();
}
public override void Update(GameTime gameTime)
{
base.Update(gameTime);
}
public override void Draw(GameTime gameTime)
{
//if (backgroundImage != null)
//{
spriteBatch = new SpriteBatch(base.GraphicsDevice);
if (Game.Services.GetService(typeof(SpriteBatch)) == null)
Game.Services.AddService(typeof(SpriteBatch), spriteBatch);
Rectangle screen = new Rectangle(0, 0,
Game.Window.ClientBounds.Width,
Game.Window.ClientBounds.Height);
Texture2D lauT2D = this.Game.Content.Load<Texture2D>("Textures/BG");
spriteBatch.Draw(lauT2D, screen, Color.White);
//}
///SpriteFont font = this.Game.Content.Load<SpriteFont>("Fonts/MenuFont");
///Vector2 spritePosition = Vector2.One;
///spriteBatch.DrawString(font, "Goodness ME", spritePosition, Color.White);
base.Draw(gameTime);
}
}
나는 GraphicDevice과의 SpriteBatch를 초기화하기 전에 창을 여는 방법은 완전히 혼란 스러워요 실제 게임이 실행/초기화됩니다. KRZ
나는 DrawableGameComponent 또는 UI 화면을 만드는 데 사용되는 것을로드하는 중이었습니다. 또한 Windows Phone 용 VS 2010 Express를 사용하고 있으며 Windows Form 템플릿을 포함 할 수 있습니까? – srcKode
원하는 것을 할 수있는 DrawableGameComponent에 대한 소스를 추가했습니다. 양식 표시/숨기기를 사용/사용 중지하기 만하면됩니다. – Blau
게임을 시작하기 전에 팝업 창이 새 창 양식을 의미한다고 생각합니다. 화면 관리자 시스템 만 필요하다고 생각합니다. 화면이나 팝업을 게임에 포함 시키시겠습니까? – Blau