XNA 益智游戏如何点击鼠标 [英] XNA Puzzle Game how to mouse click

查看:37
本文介绍了XNA 益智游戏如何点击鼠标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在到处搜索,但我不知道该怎么做才能让光标能够点击某个磁贴并将其删除,这样它上面的其他磁贴就可以掉下来了.

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

推荐答案

你在问什么,如何使用 MouseClick?怎么让瓷砖掉下来?或如何制作随机瓷砖?由于您的标题不适用于鼠标单击.(顺便说一句,为瓷砖制作一个随机列表,然后将它们随机排列,只需谷歌一下)

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.

这篇关于XNA 益智游戏如何点击鼠标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆