设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 2059|回复: 6
打印 上一主题 下一主题

[已经过期] 关于一个新鼠标系统

[复制链接]

Lv3.寻梦者

梦石
0
星屑
3846
在线时间
1966 小时
注册时间
2013-1-3
帖子
9536
跳转到指定楼层
1
发表于 2013-8-12 14:23:05 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

x
本帖最后由 紫英晓狼1130 于 2013-8-14 15:52 编辑

@弗雷德 ,那个脚本不用改了,我找了个新的
在没有外来脚本的情况下,只要屏幕一移动,鼠标图就不会改成对话或者小手了
神奇的是我把脚本转到一个新工程就好使了
可能我问题描述的不清楚,希望能帮我看一下...
好像画面卷动出了问题...


鼠标
  1. class Game_Event
  2.   attr_accessor :flag
  3. end

  4. #==============================================================================
  5. # ■ Game_Map
  6. #------------------------------------------------------------------------------
  7. #  处理地图的类。包含卷动以及可以通行的判断功能。
  8. # 本类的实例请参考 $game_map 。
  9. #==============================================================================

  10. class Game_Map
  11.   def check_event_custom(x, y)
  12.     for event in $game_map.events.values
  13.       if event.screen_x/32 == x and event.screen_y/32-1 == y
  14.         for i in 0...event.list.size
  15.           if event.list[i].parameters[0] == "enemy"
  16.             event.flag = 1
  17.           elsif event.list[i].parameters[0] == "npc"
  18.             event.flag = 2
  19.           elsif event.list[i].parameters[0] == "chest"
  20.             event.flag = 3
  21.           else
  22.             event.flag = 0
  23.           end
  24.           return event.flag
  25.         end
  26.       end
  27.     end
  28.   end
  29. end
  30. #==============================================================================
  31. # 本脚本来自www.66rpg.com,源自geocities.jp,转载和使用请注明此内容
  32. #
  33. # 初始鼠标图案在35行和64行改,变换的鼠标图案在62行改
  34. # 这个脚本的思路是判断鼠标所在位置是否有事件,所以响应的情况只有一种。
  35. # 如果想有多种响应的话,思路复杂,比如拆分事件名称等,做出来的东西将繁琐。
  36. #                                                           —— JesseKiss
  37. #==============================================================================
  38. #=================以下两个用来调整战斗时的手感问题,可以自己试试。
  39. $敌人选框扩大 = 20
  40. $角色选框扩大 = 30
  41. #==============================================================================
  42. # API调用
  43. #==============================================================================
  44. $ShowCursor = Win32API.new("user32", "ShowCursor", 'i', 'l')
  45. $GetCursorPos = Win32API.new("user32", "GetCursorPos", 'p', 'i')
  46. $ScreenToClient = Win32API.new("user32", "ScreenToClient", 'ip', 'i')
  47. $GetActiveWindow = Win32API.new("user32", "GetActiveWindow", nil, 'l')
  48. $Window_HWND = $GetActiveWindow.call
  49. $GetKeyState = Win32API.new("user32", "GetKeyState", 'i', 'i')
  50. #$FindWindow = Win32API.new("user32", "FindWindow", 'pp', 'i')
  51. #$HookStart  = Win32API.new("mouse_hook.dll", "HookStart", 'i', nil)
  52. #$HookEnd  = Win32API.new("mouse_hook.dll", "HookEnd", nil, nil)
  53. #$GetMouseStatus  = Win32API.new("mouse_hook.dll", "GetMouseStatus", 'i', 'i')
  54. #$Window_HWND = $FindWindow.call(nil, 'mousetry')

  55. module Mouse  
  56.   LEFT = 0x01
  57.   RIGHT = 0x02

  58.   def self.init(sprite = nil)
  59. #   $HookStart.call($Window_HWND)
  60.     $ShowCursor.call(0)
  61.    
  62.     @show_cursor = false
  63.    
  64.     @mouse_sprite = Sprite.new
  65.     @mouse_sprite.z = 99999
  66.     @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/028-Herb04.png')
  67.     #@mouse_sprite.bitmap.fill_rect(Rect.new(0, 0, 32, 32), Color.new(0, 0, 0))

  68.     @left_press = false
  69.     @right_press = false
  70.     @left_trigger = false
  71.     @right_trigger = false
  72.     @left_repeat = false
  73.     @right_repeat = false
  74.     @click_lock = false
  75.     if @a == nil
  76.       @a = true
  77.       @total_sec = Graphics.frame_count * 3 / Graphics.frame_rate
  78.     end
  79.     update
  80.   end
  81.   def self.exit
  82.     @mouse_sprite.bitmap.dispose
  83.     @mouse_sprite.dispose
  84.     @show_cursor = true
  85. #    $HookEnd.call
  86.     $ShowCursor.call(1)
  87.   end
  88.   def self.mouse_debug
  89.     return @mouse_debug.bitmap
  90.   end
  91.   def self.refresh
  92.   end
  93.   def self.update
  94.     left_down = $GetKeyState.call(0x01)
  95.     right_down = $GetKeyState.call(0x02)
  96.     if Graphics.frame_count * 3 / Graphics.frame_rate != @total_sec
  97.       @total_sec = Graphics.frame_count * 3 / Graphics.frame_rate
  98.       @a = !@a
  99.     end
  100.     case $pop
  101.     when 1
  102.       if @a
  103.         @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/1.png')
  104.       else
  105.         @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/11.png')
  106.       end
  107.     when 2
  108.       if @a
  109.         @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/2.png')
  110.       else
  111.         @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/22.png')
  112.       end
  113.     when 3
  114.       if @a
  115.         @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/3.png')
  116.       else
  117.         @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/33.png')
  118.       end
  119.     else
  120.       @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/028-Herb04.png')
  121.     end
  122.     @click_lock = false
  123.     mouse_x, mouse_y = self.get_mouse_pos
  124.     if @mouse_sprite != nil
  125.       @mouse_sprite.x = mouse_x
  126.       @mouse_sprite.y = mouse_y
  127.     end
  128.     if left_down[7] == 1
  129.       @left_repeat = (not @left_repeat)
  130.       @left_trigger = (not @left_press)
  131.       @left_press = true
  132.     else
  133.       @left_press = false
  134.       @left_trigger = false
  135.       @left_repeat = false
  136.     end
  137.     if right_down[7] == 1
  138.       @right_repeat = (not @right_repeat)
  139.       @right_trigger = (not @right_press)
  140.       @right_press = true
  141.     else
  142.       @right_press = false
  143.       @right_trigger = false
  144.       @right_repeat = false
  145.     end
  146.   end
  147.   def self.get_mouse_pos
  148.     point_var = [0, 0].pack('ll')
  149.     if $GetCursorPos.call(point_var) != 0
  150.       if $ScreenToClient.call($Window_HWND, point_var) != 0
  151.         x, y = point_var.unpack('ll')
  152.         if (x < 0) or (x > 10000) then x = 0 end
  153.         if (y < 0) or (y > 10000) then y = 0 end
  154.         if x > 640 then x = 640 end
  155.         if y > 480 then y = 480 end
  156.         return x, y
  157.       else
  158.         return 0, 0
  159.       end
  160.     else
  161.       return 0, 0
  162.     end
  163.   end
  164.   def self.press?(mouse_code)
  165.     if mouse_code == LEFT
  166.       if @click_lock
  167.         return false
  168.       else
  169.         return @left_press
  170.       end
  171.     elsif mouse_code == RIGHT
  172.       return @right_press
  173.     else
  174.       return false
  175.     end
  176.   end
  177.   def self.trigger?(mouse_code)
  178.     if mouse_code == LEFT
  179.       if @click_lock
  180.         return false
  181.       else
  182.         return @left_trigger
  183.       end
  184.     elsif mouse_code == RIGHT
  185.       return @right_trigger
  186.     else
  187.       return false
  188.     end
  189.   end
  190.   def self.repeat?(mouse_code)
  191.     if mouse_code == LEFT
  192.       if @click_lock
  193.         return false
  194.       else
  195.         return @left_repeat
  196.       end
  197.     elsif mouse_code == RIGHT
  198.       return @right_repeat
  199.     else
  200.       return false
  201.     end
  202.   end
  203.   def self.click_lock?
  204.     return @click_lock
  205.   end
  206.   def self.click_lock
  207.     @click_lock = true
  208.   end
  209.   def self.click_unlock
  210.     @click_lock = false
  211.   end
  212. end
  213. module Input
  214.   if @self_update == nil
  215.     @self_update = method('update')
  216.     @self_press = method('press?')
  217.     @self_trigger = method('trigger?')
  218.     @self_repeat = method('repeat?')
  219.   end
  220.   def self.update
  221.     @self_update.call
  222.     Mouse.update
  223.   end
  224.   def self.press?(key_code)
  225.     if @self_press.call(key_code)
  226.       return true
  227.     end
  228.     if key_code == C
  229.       return Mouse.press?(Mouse::LEFT)
  230.     elsif key_code == B
  231.       return Mouse.press?(Mouse::RIGHT)
  232.     else
  233.       return @self_press.call(key_code)
  234.     end
  235.   end
  236.   def self.trigger?(key_code)
  237.     if @self_trigger.call(key_code)
  238.       return true
  239.     end
  240.     if key_code == C
  241.       return Mouse.trigger?(Mouse::LEFT)
  242.     elsif key_code == B
  243.       return Mouse.trigger?(Mouse::RIGHT)
  244.     else
  245.       return @self_trigger.call(key_code)
  246.     end
  247.   end
  248.   def self.repeat?(key_code)
  249.     if @self_repeat.call(key_code)
  250.       return true
  251.     end
  252.     if key_code == C
  253.       return Mouse.repeat?(Mouse::LEFT)
  254.     elsif key_code == B
  255.       return Mouse.repeat?(Mouse::RIGHT)
  256.     else
  257.       return @self_repeat.call(key_code)
  258.     end
  259.   end
  260. end
  261. class Window_Selectable
  262.   if @self_alias == nil
  263.     alias self_update update
  264.     @self_alias = true
  265.   end
  266.   def update
  267.     #self.cursor_rect.empty
  268.     self_update
  269.     if self.active and @item_max > 0
  270.       index_var = @index
  271.       tp_index = @index
  272.       mouse_x, mouse_y = Mouse.get_mouse_pos
  273.       mouse_not_in_rect = true
  274.       for i in 0...@item_max
  275.         [url=home.php?mod=space&uid=370741]@Index[/url] = i
  276.         update_cursor_rect
  277.         top_x = self.cursor_rect.x + self.x + 16
  278.         top_y = self.cursor_rect.y + self.y + 16
  279.         bottom_x = top_x + self.cursor_rect.width
  280.         bottom_y = top_y + self.cursor_rect.height
  281.         if (mouse_x > top_x) and (mouse_y > top_y) and
  282.            (mouse_x < bottom_x) and (mouse_y < bottom_y)
  283.           mouse_not_in_rect = false
  284.           if tp_index != @index
  285.             tp_index = @index
  286.             $game_system.se_play($data_system.cursor_se)
  287.           end
  288.           break
  289.         end
  290.       end
  291.       if mouse_not_in_rect
  292.         @index = index_var
  293.         update_cursor_rect
  294.         Mouse.click_lock
  295.       else
  296.         Mouse.click_unlock               
  297.       end
  298.     end
  299.   end
  300. end
  301. class Window_NameInput
  302.   if @self_alias == nil
  303.     alias self_update update
  304.     @self_alias = true
  305.   end
  306.   def update
  307.     #self.cursor_rect.empty
  308.     self_update
  309.     if self.active
  310.       index_var = @index
  311.       mouse_x, mouse_y = Mouse.get_mouse_pos
  312.       mouse_not_in_rect = true
  313.       for i in (0...CHARACTER_TABLE.size).to_a.push(180)
  314.         @index = i
  315.         update_cursor_rect
  316.         top_x = self.cursor_rect.x + self.x + 16
  317.         top_y = self.cursor_rect.y + self.y + 16
  318.         bottom_x = top_x + self.cursor_rect.width
  319.         bottom_y = top_y + self.cursor_rect.height
  320.         #
  321.         if (mouse_x > top_x) and (mouse_y > top_y) and
  322.            (mouse_x < bottom_x) and (mouse_y < bottom_y)
  323.           mouse_not_in_rect = false
  324.           break
  325.         end
  326.       end
  327.       if mouse_not_in_rect
  328.         @index = index_var
  329.         update_cursor_rect
  330.         Mouse.click_lock
  331.       else
  332.         Mouse.click_unlock
  333.       end
  334.     end
  335.   end
  336. end
  337. class Window_InputNumber
  338.   if @self_alias == nil
  339.     alias self_update update
  340.     @self_alias = true
  341.   end
  342.   def update
  343.     #self.cursor_rect.empty
  344.     self_update
  345.     mouse_x, mouse_y = Mouse.get_mouse_pos
  346.     if self.active and @digits_max > 0
  347.       index_var = @index
  348.       mouse_not_in_rect = true
  349.       for i in 0...@digits_max
  350.         @index = i
  351.         update_cursor_rect
  352.         top_x = self.cursor_rect.x + self.x + 16
  353.         bottom_x = top_x + self.cursor_rect.width
  354.         #
  355.         if (mouse_x > top_x) and (mouse_x < bottom_x)
  356.           mouse_not_in_rect = false
  357.           break
  358.         end
  359.       end
  360.       if mouse_not_in_rect
  361.         @index = index_var
  362.         update_cursor_rect
  363.         Mouse.click_lock
  364.       else
  365.         Mouse.click_unlock
  366.       end
  367.     end
  368.     if @last_mouse_y == nil
  369.       @last_mouse_y = mouse_y
  370.     end
  371.     check_pos = (@last_mouse_y - mouse_y).abs
  372.     if check_pos > 10
  373.       $game_system.se_play($data_system.cursor_se)
  374.       place = 10 ** (@digits_max - 1 - @index)
  375.       n = [url=home.php?mod=space&uid=27178]@Number[/url] / place % 10
  376.       [url=home.php?mod=space&uid=27178]@Number[/url] -= n * place
  377.       n = (n + 1) % 10 if mouse_y < @last_mouse_y
  378.       n = (n + 9) % 10 if mouse_y > @last_mouse_y
  379.       @number += n * place
  380.       refresh
  381.       @last_mouse_y = mouse_y
  382.     end
  383.   end
  384. end
  385. class Scene_File
  386.   if @self_alias == nil
  387.     alias self_update update
  388.     @self_alias = true
  389.   end
  390.   def update
  391.     mouse_x, mouse_y = Mouse.get_mouse_pos
  392.     Mouse.click_lock
  393.     idx = 0
  394.     for i in @savefile_windows
  395.       top_x = i.x + 16
  396.       top_y = i.y + 16
  397.       bottom_x = top_x + i.width
  398.       bottom_y = top_y + i.height
  399.       if (mouse_x > top_x) and (mouse_y > top_y) and
  400.          (mouse_x < bottom_x) and (mouse_y < bottom_y)
  401.         i.selected = true
  402.         if @file_index != idx
  403.           @file_index = idx
  404.           $game_system.se_play($data_system.cursor_se)
  405.         end            
  406.         Mouse.click_unlock
  407.       else
  408.         i.selected = false
  409.       end
  410.       idx += 1
  411.     end
  412.     self_update
  413.   end
  414. end
  415. class Arrow_Enemy
  416.   if @self_alias == nil
  417.     alias self_update update
  418.     @self_alias = true
  419.   end
  420.   def update
  421.     mouse_x, mouse_y = Mouse.get_mouse_pos
  422.     idx = 0
  423.     for i in $game_troop.enemies do
  424.       if i.exist?
  425.         top_x = i.screen_x - self.ox
  426.         top_y = i.screen_y - self.oy
  427.         bottom_x = top_x + self.src_rect.width
  428.         bottom_y = top_y + self.src_rect.height
  429.         if (mouse_x > top_x - $敌人选框扩大) and (mouse_y > top_y - $敌人选框扩大) and
  430.            (mouse_x < bottom_x + $敌人选框扩大) and (mouse_y < bottom_y + $敌人选框扩大)
  431.           if @index != idx
  432.             $game_system.se_play($data_system.cursor_se)
  433.             @index = idx
  434.           end
  435.         end
  436.       end
  437.       idx += 1
  438.     end
  439.     self_update
  440.   end
  441. end
  442. class Arrow_Actor
  443.   if @self_alias == nil
  444.     alias self_update update
  445.     @self_alias = true
  446.   end
  447.   def update
  448.     mouse_x, mouse_y = Mouse.get_mouse_pos
  449.     idx = 0
  450.     for i in $game_party.actors do
  451.       if i.exist?
  452.         top_x = i.screen_x - self.ox
  453.         top_y = i.screen_y - self.oy
  454.         bottom_x = top_x + self.src_rect.width
  455.         bottom_y = top_y + self.src_rect.height
  456.         if (mouse_x > top_x - $角色选框扩大) and (mouse_y > top_y - $角色选框扩大) and
  457.            (mouse_x < bottom_x + $角色选框扩大) and (mouse_y < bottom_y + $角色选框扩大)
  458.           if @index != idx
  459.             $game_system.se_play($data_system.cursor_se)
  460.             @index = idx
  461.           end
  462.         end
  463.       end
  464.       idx += 1
  465.     end
  466.     self_update
  467.   end
  468. end
  469. class Game_Player
  470.   if @self_alias == nil
  471.     alias self_update update
  472.     @self_alias = true
  473.   end
  474.   def update
  475.     mouse_x, mouse_y = Mouse.get_mouse_pos
  476.     unless $game_system.map_interpreter.running?
  477.       $pop = $game_map.check_event_custom(mouse_x/32,mouse_y/32)
  478.     else
  479.       $pop = 0
  480.     end
  481.     if @last_move_x == nil
  482.       @last_move_x = false
  483.     end
  484.     if Mouse.press?(Mouse::LEFT)
  485.       last_moving = moving?
  486.       last_direction = @direction
  487.       unless moving? or $game_system.map_interpreter.running? or
  488.              @move_route_forcing or $game_temp.message_window_showing
  489.         last_x = @x
  490.         if @last_move_x
  491.           @last_move_x = false
  492.         elsif mouse_x > screen_x + 16
  493.           move_right
  494.         elsif mouse_x < screen_x - 16
  495.           move_left
  496.         end
  497.         last_y = @y
  498.         if last_x != @x
  499.           @last_move_x = true
  500.         elsif mouse_y > screen_y
  501.           move_down
  502.         elsif mouse_y < screen_y - 32
  503.           move_up
  504.         end
  505.         if last_y != @y
  506.           @last_move_x = false
  507.         elsif not @last_move_x
  508.           case last_direction
  509.           when 2
  510.             turn_down
  511.           when 4
  512.             turn_left
  513.           when 6
  514.             turn_right
  515.           when 8
  516.             turn_up
  517.           end
  518.         end
  519.       end
  520.     end
  521.     self_update
  522.   end
  523. end
  524. Mouse.init
  525. END { Mouse.exit }
复制代码
这是所需的素材,替换Icon包
Icons.rar (5.57 KB, 下载次数: 58)   

点评

解决不能……好奇怪……  发表于 2013-8-12 22:54
《宿愿·寻剑篇》正式版已经发布!快去看看!点击进入论坛发布贴

Lv2.观梦者

梦石
0
星屑
687
在线时间
791 小时
注册时间
2011-10-20
帖子
2394

开拓者

2
发表于 2013-8-12 14:49:27 | 只看该作者
if event.screen_x/32 == x and event.screen_y/32-1 == y

掩笑逃之
貌似LZ说半天没有提问而是抒情。。

点评

好神奇。。  发表于 2013-8-12 15:34
改过了,这个好像只能改变鼠标的位置。而这个脚本在我的游戏里屏幕只要一刷新就没法变鼠标了,把所有外来脚本都删除了,还是如此…  发表于 2013-8-12 15:02
欢迎点此进入我的egames.wink.ws,有RMQQ堂等

[url=http://rpg.blue/thread-317273-1-1.html]短篇八-赶选

http://yun.baidu.com/share/link?shareid=2158225779&uk=169642147&third=0


历险ARPG赢回你的疆域新的战斗模式?…………点击这里:[宋乱贼狂 for QQ堂]
http://rpg.blue/group-368-1.html
programing ....?
[url=http://rpg.blue/thrd-234658-1-1.html]
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
3846
在线时间
1966 小时
注册时间
2013-1-3
帖子
9536
3
 楼主| 发表于 2013-8-14 15:52:52 | 只看该作者
补充了一下帖子,希望能解决
《宿愿·寻剑篇》正式版已经发布!快去看看!点击进入论坛发布贴
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
27 小时
注册时间
2013-7-28
帖子
23
4
发表于 2013-8-14 16:58:10 | 只看该作者
呜呜呜。。。。。果然看高人的游戏及脚本会伤人自尊。。。。。。。。。
回复 支持 反对

使用道具 举报

Lv2.观梦者

故九江太守

梦石
0
星屑
573
在线时间
2161 小时
注册时间
2012-12-5
帖子
4463
5
发表于 2013-8-18 02:08:47 | 只看该作者
鼠标脚本到现在都还没有完美的嘛= =
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
141 小时
注册时间
2013-8-6
帖子
114
6
发表于 2013-8-19 09:11:12 | 只看该作者
首先不说写的内容,这一看就是个不太专业的脚本。作者可能是偷懒还是什么,整页脚本没有一个注释,类与类挤在一起,很难马上看懂那部分是干嘛的。
其次我觉得用事件名来判断比较方便,当然用parameter也不是不可以,不过他的判断方法似乎是有问题的。我觉得根据事件本身的位置判断要比根据光标位置判断来的直接。有空可以修改下。
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
3846
在线时间
1966 小时
注册时间
2013-1-3
帖子
9536
7
 楼主| 发表于 2013-8-21 06:23:58 | 只看该作者
Algalon 发表于 2013-8-19 09:11
首先不说写的内容,这一看就是个不太专业的脚本。作者可能是偷懒还是什么,整页脚本没有一个注释,类与类挤 ...

这个位置是用事件的位置为基础,再用坐标修正得到的
《宿愿·寻剑篇》正式版已经发布!快去看看!点击进入论坛发布贴
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-9-29 21:21

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表