2012-04-17 7 views
1

Windowsの電話機7 XNAにメニューボタンのタイプはありますか? Cocos2DでCCMEnuのような私のゲームのメニューボタンを作りたいですか? これは私のGamePage.xaml.csです。XNAのメニューボタン

public GamePage() 
    { 
     InitializeComponent(); 

     newButton = new Button(); 
     newButton.Height = 75; 
     newButton.Width = 250; 
     ///newButton.Foreground = new System.Windows.Media.SolidColorBrush(Colors.Green); 
     newButton.Content = "Dynamically added"; 


     // Get the content manager from the application 
     contentManager = (Application.Current as App).Content; 
     contentManager.RootDirectory = "Content"; 

     // Create a timer for this page 
     timer = new GameTimer(); 
     timer.UpdateInterval = TimeSpan.FromTicks(333333); 
     timer.Update += OnUpdate; 
     timer.Draw += OnDraw; 

     newButton.Click += new RoutedEventHandler(newButton_Click); 
    } 

    void setUpBackgroundAndTitle() 
    { 
     // Draw a background picture with scaling since the picture is large // 
     spriteBatch.Draw(background, new Vector2(0, 0), null, Color.White, 0f, Vector2.Zero, new Vector2(0.9f, 0.9f), SpriteEffects.None, 0f); 
     spriteBatch.Draw(rhymeImage, new Vector2(400, 0), null, Color.White, 0f, Vector2.Zero, new Vector2(1f, 1f), SpriteEffects.None, 1f); 
     spriteBatch.Draw(gameImage, new Vector2(180, 0), null, Color.White, 0f, Vector2.Zero, new Vector2(1f, 1f), SpriteEffects.None, 1f); 
     spriteBatch.Draw(titleImage, new Vector2(150, -70), null, Color.White, 0f, Vector2.Zero, new Vector2(1f, 1f), SpriteEffects.None, 1f); 
     ContentPanel.Children.Add(newButton); 
    } 

xamlファイル。

<Button Content="Button" Height="71" Name="button1" Width="160" Click="button1_Click" /> 

答えて

1

XNAだけではなく、Silverlight + XNAレシピを使用するのはなぜですか?

そのようにすれば、XNAでそれらを一から描画するのではなく、Silverlightのボタン(ボタンのような)をすべて使用することができます!

Windows Phone Code Samplesの「Silverlight/XNA Frameworkサンプル」サンプルを確認してください。

+0

ボタンをバックグラウンドの下に置いていたらOKです。どのように前にそれをもたらす。または、どうやってボタンを動的に作成できますか? – user1323210

+0

ちょうど推測ですが、それはおそらくOnDrawメソッドのメソッドの順序に関係しています... Silverlight要素のレンダリングはメソッドの最後のものにする必要があります(上にとどまるため) –

+0

このボタンはXML。どのようにトップに持っていくのか。 – user1323210

関連する問題