我创建了一个按钮图像并命名它Texture2D btn_play
。它用于主菜单,我想按它来更改CurrentGameState
.
我的变量:
GraphicsDeviceManager graphics;
SpriteBatch spriteBatch;
Texture2D Tex_Btn_play;
Rectangle Rec_Btn_play;
enum Menu
{
MainMenu,
Playing,
Exit,
}
Menu CurrentGameState = Menu.MainMenu;
和Update
方法:
protected override void Update(GameTime gameTime)
{
// Allows the game to exit
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
this.Exit();
if (Rec_Btn_play = TouchLocationState.Pressed);
// TODO: Add your update logic here
base.Update(gameTime);
}
是错的if (Rec_Btn_play = TouchLocationState.Pressed);
,我不知道为什么。请帮我解决这个问题。