xna - How do I use a image photo as a Windows phone Button -


i created button image , named texture2d btn_play. main menu , want press change currentgamestate.

my variables:

    graphicsdevicemanager graphics;     spritebatch spritebatch;      texture2d tex_btn_play;     rectangle rec_btn_play;      enum menu     {         mainmenu,         playing,         exit,     }      menu currentgamestate = menu.mainmenu; 

and update method:

protected override void update(gametime gametime) {     // allows game exit     if (gamepad.getstate(playerindex.one).buttons.back == buttonstate.pressed)         this.exit();      if (rec_btn_play = touchlocationstate.pressed);     // todo: add update logic here      base.update(gametime); } 

the if (rec_btn_play = touchlocationstate.pressed); wrong, don't know why. please me solve problem.

you need find touch locations , check if rectangle intersects position

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         }      } } 

Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -