2013-05-04 49 views
0

我创建了一个按钮图片,我将它命名为Texture2D btn_play。这是一个主菜单,我想按它来更改CurrentGameState如何使用图片照片作为Windows手机按钮

我的变量:

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);是错的,我不知道为什么。请帮我解决这个问题。

+0

我不明白为什么这个问题是downvoted相交。有没有很好的理由,还是仅仅因为他不知道其他人认为基本的东西? – 2013-05-06 15:49:08

+0

呵呵thx im srr如果它是一个基本的问题是,即时通讯17岁,并从互联网学习东西我开始学习时,我13岁..我尽我所能,所以我可以成为一家游戏公司这将是我的生活:) xD – 2013-05-06 20:48:20

回答

0

你需要找到触摸位置和检查矩形与位置

TouchCollection touchCollection = TouchPanel.GetState(); 
foreach (TouchLocation tl in touchCollection) 
{ 
    if (tl.State == TouchLocationState.Pressed) 
    { 
     if (Rct_Btn_Play.Contains(new Point(tl.Position.X,tl.Position.Y)) 
     { 
      //DoStuff 
     } 

    } 
} 
+0

Thxxx Cyral你是对的,我也读过你的游戏xDDD Cyral我有另外一个问题吗? – 2013-05-04 22:24:26

+0

没问题!很高兴你看到了我的比赛。是的,在这里,如果你仍然需要帮助,你应该问另一个问题(提供代码,研究等) – Cyral 2013-05-05 00:34:15

相关问题