Project1

标题: 关于定位x,y坐标的问题 [打印本页]

作者: 邱小谦    时间: 2016-3-19 23:23
标题: 关于定位x,y坐标的问题
#-----------------------------------------------------------------------------
#by 个快快
#对于以前的那些高仿梦单,判断鼠标坐标一般采用command选项的方式,其实这样不是很科学
#尝试技能脚本后,我终于放弃了这种方式……局限性太大了
#所以,决定写一个判断格子坐标的方法。
#----------------------------------------------------------------------------
#●●●●●●●●●●
#●格子坐标判断v1.0●
#●●●●●●●●●●
class Area
        def initialize(x,y,num,width,height,row,weights,heights,zero = 0,one = 0)
                #X坐标,Y坐标,数量,格子宽度,格子高度,每行数目,总宽度,总长度,间隔
                @x = x
                @y = y
                @num = num
                @width = width
                @height = height
                @zero = zero
                @one = one
                @row = row
                @weights = weights
                @heights = heights
                p @one
        end
        def count
                #获取鼠标坐标
                mouse_x, mouse_y = Mouse.get_mouse_pos
                if mouse_x > @x and mouse_y >@y and mouse_x < @x+@weights and mouse_y < @y+@heights
                        if @zero == 0
                                h = (mouse_y-@y)/@height
                                l = (mouse_x-@x)/@width +1
                                number = h*@row +l
                                if number <= @num
                                        p
                                        return number
                                else
                                        return 0
                                end
                        else
                                h = (mouse_y-@y)/@height
                                l = (mouse_x-@x)/(@width+@zero) +1
                                number = h*@row + l
                                if mouse_x > @x + (l-1)*(@width+@zero) and mouse_x < @x + (l-1)*(@width+@zero)+@width
                                        if number <= @num
                                                return number
                                        else
                                                return 0
                                        end
                                else
                                        return 0
                                end
                        end
                else
                        return 0
                end
        end
end
我想在这段代码里面添加一段代码来判定鼠标在第一行第一个图标到第一行第二个图标的距离。。也就是说,鼠标放在第一个图标的位置上和第二个图标的位置中间的空空不显示说明,但是当鼠标移动到第二个图标才显示图标说明的效果。。。




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1