1
windows phone 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" />
好的,當我這樣做了,按鈕是低於背景。如何把它帶到前面。或者我如何動態創建一個按鈕。 – user1323210 2012-04-17 10:58:14
只是一個猜測,但這可能與OnDraw方法中的方法順序有關... Silverlight元素呈現應該是該方法的最後一個(爲了保持最前) – 2012-04-17 11:07:51
我將此按鈕放置在xml。那麼如何把它帶到最前面。 – user1323210 2012-04-17 11:19:08