赞 | 0 |
VIP | 0 |
好人卡 | 0 |
积分 | 1 |
经验 | 20825 |
最后登录 | 2013-3-5 |
在线时间 | 3 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 50
- 在线时间
- 3 小时
- 注册时间
- 2008-8-10
- 帖子
- 243
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
最近正在筹备制作一个带有鼠标的游戏!发现每个鼠标脚本都会跟键盘抢光标,就算鼠标不移动的时候也是如此!所以本人现在找了个鼠标脚本来开刀!修改后脚本大概如下!
首先是定义一个变量判断鼠标是否是移动中状态
#鼠标是否移动
$mouse_move
然后判断鼠标是否是静止状态(这里要借助鼠标无动作淡出的脚本)
if @mouse_sprite != nil
if @old_x != @mouse_sprite.x or @old_y != @mouse_sprite.y or
Mouse.press?(Mouse::LEFT) or
Mouse.press?(Mouse::RIGHT)
@waittime = 80
@mouse_sprite.opacity = 255
###########
$mouse_move = true
###########
end
@waittime -= 1 if @waittime != 0
@mouse_sprite.opacity -= 8 if @waittime == 0 and @mouse_sprite.opacity > 0
@old_x = @mouse_sprite.x
@old_y = @mouse_sprite.y
###########
if @mouse_sprite.opacity < 100 or @waittime < 40 #这里是用透明度或者等待时间来判断鼠标是否正在使用中
$mouse_move = false
end
########### end
最后将所有有 update_cursor_rect和 mouse_not_in_rect 的脚本后面都加个判断,鼠标不移动就不刷新,其中 tp_index = @index 是将光标赋值到鼠标,也就是鼠标抢光标的罪魁祸首- -,可是这条语句又不能完全不用!所以也在后面加个判断就OK!不然鼠标就不是抢当前光标了!而是抢当前以外的光标!那就更郁闷了!- -
class Window_Selectable
if @self_alias == nil
alias self_update update
@self_alias = true
end
def update
self_update
if self.active and @item_max > 0
index_var = @index
tp_index = @index
mouse_x, mouse_y = Mouse.get_mouse_pos
mouse_not_in_rect = true
for i in 0...@item_max
@index = i
update_cursor_rect if $mouse_move#####
top_x = self.cursor_rect.x + self.x + 16
top_y = self.cursor_rect.y + self.y + 16
bottom_x = top_x + self.cursor_rect.width
bottom_y = top_y + self.cursor_rect.height
if (mouse_x > top_x) and (mouse_y > top_y) and
(mouse_x < bottom_x) and (mouse_y < bottom_y)
mouse_not_in_rect = false if $mouse_move#####
if tp_index != @index
tp_index = @index if $mouse_move#####
$game_system.se_play($data_system.cursor_se)
end
break
end
end
if mouse_not_in_rect
@index = index_var
update_cursor_rect if $mouse_move#####
Mouse.click_lock
else
Mouse.click_unlock
end
end
end
end
class Window_NameInput
if @self_alias == nil
alias self_update update
@self_alias = true
end
def update
self_update
if self.active
index_var = @index
mouse_x, mouse_y = Mouse.get_mouse_pos
mouse_not_in_rect = true
for i in (0...CHARACTER_TABLE.size).to_a.push(180)
@index = i
update_cursor_rect if $mouse_move#####
top_x = self.cursor_rect.x + self.x + 16
top_y = self.cursor_rect.y + self.y + 16
bottom_x = top_x + self.cursor_rect.width
bottom_y = top_y + self.cursor_rect.height
if (mouse_x > top_x) and (mouse_y > top_y) and
(mouse_x < bottom_x) and (mouse_y < bottom_y)
mouse_not_in_rect = false if $mouse_move#####
break
end
end
if mouse_not_in_rect
@index = index_var
update_cursor_rect if $mouse_move#####
Mouse.click_lock
else
Mouse.click_unlock
end
end
end
end
class Window_InputNumber
if @self_alias == nil
alias self_update update
@self_alias = true
end
def update
self_update
mouse_x, mouse_y = Mouse.get_mouse_pos
if self.active and @digits_max > 0
index_var = @index
mouse_not_in_rect = true
for i in 0...@digits_max
@index = i
update_cursor_rect if $mouse_move#####
top_x = self.cursor_rect.x + self.x + 16
bottom_x = top_x + self.cursor_rect.width
if (mouse_x > top_x) and (mouse_x < bottom_x)
mouse_not_in_rect = false if $mouse_move#####
break
end
end
if mouse_not_in_rect
@index = index_var
update_cursor_rect if $mouse_move#####
Mouse.click_lock
else
Mouse.click_unlock
end
end
if @last_mouse_y == nil
@last_mouse_y = mouse_y
end
check_pos = (@last_mouse_y - mouse_y).abs
if check_pos > 10
$game_system.se_play($data_system.cursor_se)
place = 10 ** (@digits_max - 1 - @index)
n = @number / place % 10
@number -= n * place
n = (n + 1) % 10 if mouse_y < @last_mouse_y
n = (n + 9) % 10 if mouse_y > @last_mouse_y
@number += n * place
refresh
@last_mouse_y = mouse_y
end
end
end
然后就OK了!所有的修改大致如此!以下是脚本(本人借用了鼠标无动作淡出来开刀的,大致上不会出现BUG或冲突)
下载地址(范例工程就不用了,反正只有一处脚本,直接插入Main之前就行)
http://rpg.blue/upload_program/g ... ��标_102588784.txt |
|