问题
I've been searching everywhere and I dont know what to do to make the cursor able to click on a tile and delete it so other tiles above it can fall down.
For that matter, anybody know how to load random tiles on the screen? There are no tutorials on puzzle games...
回答1:
What are you asking, How to use MouseClick? How to make tiles fall? or How to make random tiles? Because of your title ill go with mouseclick. (Btw, Make a random list for tiles, and Shuffle them, just Google it)
MouseState ms = Mouse.GetState();
double x = Math.Floor(((double)ms.X / (double)TILE WIDTH);
double y = Math.Floor(((double)ms.Y / (double)TILE HEIGHT);
if (ms.RightButton == ButtonState.Pressed)
{
//Add tile (tiles[x,y] = whatever, or something like that)
}
if (ms.LeftButton == ButtonState.Pressed)
{
//And so on...
}
Hope this helps, Also note, you can make it global for better performance. And next time try to clarify your question a little more.
来源:https://stackoverflow.com/questions/10540881/xna-puzzle-game-how-to-mouse-click