Project1
标题:
VX图片响应与沉影的VX鼠标整合的冲突如何河蟹?
[打印本页]
作者:
第二疯子
时间:
2009-8-6 11:50
标题:
VX图片响应与沉影的VX鼠标整合的冲突如何河蟹?
本帖最后由 第二疯子 于 2009-8-6 11:51 编辑
以下是鼠标响应图片。
class Game_Picture
def name=(str)
@name = str
end
end
class Sprite_Picture
alias update_old update
def update
update_old
return if @picture_name == "" or @picture_name[/cmd/].nil?
mx,my = Mouse.pixels_mouse_pos
lx = self.x - self.ox
rx = lx + self.bitmap.width
ty = self.y - self.oy
by = ty + self.bitmap.height
if mx < lx or mx > rx or my < ty or my > by or
self.bitmap.get_pixel(mx-lx,my-ty).alpha == 0
@picture.name = @picture.name.split(/_/)[0]+"_"
[email protected]
(/_/)[1]
return
end
if @picture.name.split(/_/)[2].nil?
@picture.name = @picture.name + "_02"
end
if Input.trigger?(13)
@picture.name.split(/_/)[0].sub(/cmd([0-9]+)/,"")
$game_temp.common_event_id = $1.to_i
end
end
end
复制代码
以下是沉影的鼠标整合:
http://rpg.blue/viewthread.php?tid=84745
第15行弹错:undefined method 'get_mouse_pos' for Mouse:Module
找不到对应的方法?
貌似是沉影的鼠标脚本中方法名称与图片响应的 'get_mouse_pos' 不一致?
但我实在是不知道该往哪下手啊。。
研究了半夜了,结果整合失败。。。
请高手指点一二。灰常感激。
作者:
zh99998
时间:
2009-8-8 09:18
帮顶……
作者:
第二疯子
时间:
2009-8-8 23:42
本帖最后由 第二疯子 于 2009-8-8 23:43 编辑
天呀~~沉影在哪里呀,沉影在哪里…………
Mouse.pixels_mouse_pos是另一个鼠标系统的方法。
应该是判断鼠标坐标并按下。
貌似沉影的鼠标系统这俩是分开的。。
作者:
zh99998
时间:
2009-8-13 07:22
mx,my = Mouse.pixels_mouse_pos
看看沉影的系统里这个方法叫啥,然后改成相应的名字试试
作者:
第二疯子
时间:
2009-8-14 21:14
愚钝啊……修改失败……
暂时改成的mx,my = Mouse.pixels
用空格实现确认。— —
...
#==============================================================================
# ** 鼠标输出模块 (修复)
#------------------------------------------------------------------------------
# by DerVVulfman
# 版本 1.2
# 08-18-2007
#------------------------------------------------------------------------------
# 建立在鼠标输出模块...
#
# by Near Fantastica
#------------------------------------------------------------------------------
# Set_Pos feature by
# Freakboy
#------------------------------------------------------------------------------
#
# CALLS:
#
# Mouse.click?
# 判断鼠标是否真的按下(Ture/False).
# 这个值控制您按下的是左/右键,还是中键
#
# Mouse.press?
# 判断鼠标是否真的按下/保持按下状态
# 这个值控制您按下的是左/右键,还是中键
# Mouse.pixels
# Mouse.pixels
# 这个值返回鼠标所在的坐标(640*480大小),如果鼠标超出游戏画面,这个值为空
#
# Mouse.tiles
# This returns the mouse's screen coordinates in map tiles. Based on the
# system's 20x15 tile size, this returns it in index values (a 0-19 width &
# a 0-14 height). This functions the same manner as Mouse.pixels.
#
# Mouse.set_pos
# This allows you to forcefully position the mouse at an x/y position within
# the game screen by pixel coordinates. Given the game's normal screen width
# of 640x480, adding: Mouse.set_pos(320,240) should position the mouse dead
# center of the gaming window.
#
# Mouse.update
# Add this routine into your update routines to update the mouse position.
# It must be called otherwise you won't get valid mouse coordinates.
#
#==============================================================================
module Mouse
@mouse_menu = 0
#--------------------------------------------------------------------------
# * 鼠标点击
# button : button
#--------------------------------------------------------------------------
def Mouse.click?(button)
return true if @keys.include?(2) and button == 2
return true if @keys.include?(button) and $click_abled
return false
end
#--------------------------------------------------------------------------
# * 鼠标击键
# button : button
#--------------------------------------------------------------------------
def Mouse.press?(button)
return true if @press.include?(button)
return false
end
#--------------------------------------------------------------------------
# * 鼠标按下
# button : button
#--------------------------------------------------------------------------
def Mouse.area?(x, y, width=32, height=32)
return false if @pos == nil
return true if @pos[0] >= x and @pos[0] <= (x+width) and @pos[1] >= y and @pos[1] <= (y+height)
return false
end
#--------------------------------------------------------------------------
# * 坐标
#--------------------------------------------------------------------------
def Mouse.pixels
return @pos == nil ? [0, 0] : @pos
end
#--------------------------------------------------------------------------
# * 鼠标初始坐标
#--------------------------------------------------------------------------
def Mouse.tiles
return nil if @pos == nil
x = @pos[0] / 32
y = @pos[1] / 32
return [x, y]
end
#--------------------------------------------------------------------------
# * 设置鼠标初始坐标
#--------------------------------------------------------------------------
def Mouse.set_pos(x_pos=0, y_pos=0)
width, height = Mouse.client_size
if (x_pos.between?(0, width) && y_pos.between?(0, height))
x = Mouse.client_pos[0] + x_pos; y = Mouse.client_pos[1] + y_pos
Win32API.new('user32', 'SetCursorPos', 'NN', 'N').call(x, y)
end
end
#--------------------------------------------------------------------------
# * Mouse Update
#--------------------------------------------------------------------------
def Mouse.update
@pos = Mouse.pos
@keys, @press = [], []
@keys.push(1) if Win32API.new("user32","GetAsyncKeyState",['i'],'i').call(1) & 0X01 == 1
@keys.push(2) if Win32API.new("user32","GetAsyncKeyState",['i'],'i').call(2) & 0X01 == 1
@keys.push(3) if Win32API.new("user32","GetAsyncKeyState",['i'],'i').call(4) & 0X01 == 1
@press.push(1) if Win32API.new("user32","GetKeyState",['i'],'i').call(1) & 0X01 == 1
@press.push(2) if Win32API.new("user32","GetKeyState",['i'],'i').call(2) & 0X01 == 1
@press.push(3) if Win32API.new("user32","GetKeyState",['i'],'i').call(4) & 0X01 == 1
end
#--------------------------------------------------------------------------
# * Automatic functions below
#--------------------------------------------------------------------------
#
#--------------------------------------------------------------------------
# * Obtain Mouse position in screen
#--------------------------------------------------------------------------
def Mouse.global_pos
pos = [0, 0].pack('ll')
if Win32API.new('user32', 'GetCursorPos', 'p', 'i').call(pos) != 0
return pos.unpack('ll')
else
return nil
end
end
#--------------------------------------------------------------------------
# * 返回鼠标坐标
#--------------------------------------------------------------------------
def Mouse.pos
x, y = Mouse.screen_to_client(*Mouse.global_pos)
width, height = Mouse.client_size
begin
if (x >= 0 and y >= 0 and x < width and y < height)
return x, y
else
return nil
end
rescue
return nil
end
end
#--------------------------------------------------------------------------
# * Pass Screen to Game System
#--------------------------------------------------------------------------
def Mouse.screen_to_client(x, y)
return nil unless x and y
pos = [x, y].pack('ll')
if Win32API.new('user32', 'ScreenToClient', %w(l p), 'i').call(Mouse.hwnd, pos) != 0
return pos.unpack('ll')
else
return nil
end
end
#--------------------------------------------------------------------------
# * 得到游戏屏幕高度
#--------------------------------------------------------------------------
def Mouse.hwnd
game_name = "\0" * 256
Win32API.new('kernel32', 'GetPrivateProfileStringA', %w(p p p p l p), 'l').call('Game','Title','',game_name,255,".\\Game.ini")
game_name.delete!("\0")
return Win32API.new('user32', 'FindWindowA', %w(p p), 'l').call('RGSS Player',game_name)
end
#--------------------------------------------------------------------------
# * 得到游戏屏幕宽度
#--------------------------------------------------------------------------
def Mouse.client_size
rect = [0, 0, 0, 0].pack('l4')
Win32API.new('user32', 'GetClientRect', %w(l p), 'i').call(Mouse.hwnd, rect)
right, bottom = rect.unpack('l4')[2..3]
return right, bottom
end
#--------------------------------------------------------------------------
# * 得到窗口坐标
#--------------------------------------------------------------------------
def Mouse.client_pos
rect = [0, 0, 0, 0].pack('l4')
Win32API.new('user32', 'GetWindowRect', %w(l p), 'i').call(Mouse.hwnd, rect)
left, upper = rect.unpack('l4')[0..1]
return left+4, upper+30
end
end
复制代码
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1