XNA Puzzle Game how to mouse click [closed]

雨燕双飞 提交于 2019-12-25 08:28:54

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!