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

Project1

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

[已经解决] 【求助帖】鼠标脚本怎么使用系统默认的鼠标图形?

[复制链接]

Lv2.观梦者

铃铃塔的守护者

梦石
0
星屑
626
在线时间
961 小时
注册时间
2010-10-24
帖子
2768

贵宾

跳转到指定楼层
1
发表于 2010-12-26 12:15:15 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 px.凤翔九天 于 2010-12-26 14:00 编辑

完全不会改啊...改了半天,不是鼠标没图形了,就是指定的图形,这样貌似没什么问题,但是使用print等弹窗方法时无法看到鼠标....导致无法点击....(其实能,只是看不到图形了....)
求解法(貌似不是什么难的问题,只是小凤我实力还不够啊...)
脚本:
  1. #===========================================================
  2. #===================
  3. # 本脚本来自http://rpg.blue/web/,使用和转载请保留此信息
  4. #==============================================================================

  5. #=================以下两个用来调整战斗时的手感问题,可以自己试试。
  6. $敌人选框扩大 = 20
  7. $角色选框扩大 = 30


  8. #==============================================================================
  9. # API调用
  10. #==============================================================================
  11. $ShowCursor = Win32API.new("user32", "ShowCursor", 'i', 'l')
  12. $GetCursorPos = Win32API.new("user32", "GetCursorPos", 'p', 'i')
  13. $ScreenToClient = Win32API.new("user32", "ScreenToClient", 'ip', 'i')
  14. $GetActiveWindow = Win32API.new("user32", "GetActiveWindow", nil, 'l')
  15. $Window_HWND = $GetActiveWindow.call
  16. $GetKeyState = Win32API.new("user32", "GetKeyState", 'i', 'i')
  17. #$FindWindow = Win32API.new("user32", "FindWindow", 'pp', 'i')#
  18. #$HookStart  = Win32API.new("mouse_hook.dll", "HookStart", 'i', nil)#
  19. #$HookEnd  = Win32API.new("mouse_hook.dll", "HookEnd", nil, nil)#
  20. #$GetMouseStatus  = Win32API.new("mouse_hook.dll", "GetMouseStatus", 'i', 'i')#
  21. #$Window_HWND = $FindWindow.call(nil, 'mousetry')#

  22. module Mouse  
  23.   LEFT = 0x01
  24.   RIGHT = 0x02

  25.   def self.init(sprite = nil)
  26.    #$HookStart.call($Window_HWND)#
  27.     $ShowCursor.call(0)
  28.    
  29.     @show_cursor = false
  30.    
  31.     @mouse_sprite = Sprite.new
  32.     @mouse_sprite.z = 99999
  33.     @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/cursor1.png')
  34.     #@mouse_sprite.bitmap.fill_rect(Rect.new(0, 0, 32, 32), Color.new(0, 0, 0))

  35.     @left_press = false
  36.     @right_press = false
  37.     @left_trigger = false
  38.     @right_trigger = false
  39.     @left_repeat = false
  40.     @right_repeat = false
  41.     @click_lock = false
  42.    
  43.     update
  44.   end
  45.   def self.exit
  46.     @mouse_sprite.bitmap.dispose
  47.     @mouse_sprite.dispose
  48.     @show_cursor = true
  49.    # $HookEnd.call#
  50.     $ShowCursor.call(1)
  51.   end
  52.   def self.mouse_debug
  53.     return @mouse_debug.bitmap
  54.   end
  55.   def self.update
  56.     left_down = $GetKeyState.call(0x01)
  57.     right_down = $GetKeyState.call(0x02)
  58.    
  59.     @click_lock = false
  60.     mouse_x, mouse_y = self.get_mouse_pos
  61.     if @mouse_sprite != nil
  62.       @mouse_sprite.x = mouse_x
  63.       @mouse_sprite.y = mouse_y
  64.     end
  65.     if left_down[7] == 1
  66.       @left_repeat = (not @left_repeat)
  67.       @left_trigger = (not @left_press)
  68.       @left_press = true
  69.     else
  70.       @left_press = false
  71.       @left_trigger = false
  72.       @left_repeat = false
  73.     end
  74.     if right_down[7] == 1
  75.       @right_repeat = (not @right_repeat)
  76.       @right_trigger = (not @right_press)
  77.       @right_press = true
  78.     else
  79.       @right_press = false
  80.       @right_trigger = false
  81.       @right_repeat = false
  82.     end
  83.   end
  84.   def self.get_mouse_pos
  85.     point_var = [0, 0].pack('ll')
  86.     if $GetCursorPos.call(point_var) != 0
  87.       if $ScreenToClient.call($Window_HWND, point_var) != 0
  88.         x, y = point_var.unpack('ll')
  89.         if (x < 0) or (x > 10000) then x = 0 end
  90.         if (y < 0) or (y > 10000) then y = 0 end
  91.         if x > 640 then x = 640 end
  92.         if y > 480 then y = 480 end
  93.         return x, y
  94.       else
  95.         return 0, 0
  96.       end
  97.     else
  98.       return 0, 0
  99.     end
  100.   end
  101.   def self.press?(mouse_code)
  102.     if mouse_code == LEFT
  103.       if @click_lock
  104.         return false
  105.       else
  106.         return @left_press
  107.       end
  108.     elsif mouse_code == RIGHT
  109.       return @right_press
  110.     else
  111.       return false
  112.     end
  113.   end
  114.   def self.trigger?(mouse_code)
  115.     if mouse_code == LEFT
  116.       if @click_lock
  117.         return false
  118.       else
  119.         return @left_trigger
  120.       end
  121.     elsif mouse_code == RIGHT
  122.       return @right_trigger
  123.     else
  124.       return false
  125.     end
  126.   end
  127.   def self.repeat?(mouse_code)
  128.     if mouse_code == LEFT
  129.       if @click_lock
  130.         return false
  131.       else
  132.         return @left_repeat
  133.       end
  134.     elsif mouse_code == RIGHT
  135.       return @right_repeat
  136.     else
  137.       return false
  138.     end
  139.   end
  140.   def self.click_lock?
  141.     return @click_lock
  142.   end
  143.   def self.click_lock
  144.     @click_lock = true
  145.   end
  146.   def self.click_unlock
  147.     @click_lock = false
  148.   end
  149. end
  150. module Input
  151.   if @self_update == nil
  152.     @self_update = method('update')
  153.     @self_press = method('press?')
  154.     @self_trigger = method('trigger?')
  155.     @self_repeat = method('repeat?')
  156.   end
  157.   def self.update
  158.     @self_update.call
  159.     Mouse.update
  160.   end
  161.   def self.press?(key_code)
  162.     if @self_press.call(key_code)
  163.       return true
  164.     end
  165.     if key_code == C
  166.       return Mouse.press?(Mouse::LEFT)
  167.     elsif key_code == B
  168.       return Mouse.press?(Mouse::RIGHT)
  169.     else
  170.       return @self_press.call(key_code)
  171.     end
  172.   end
  173.   def self.trigger?(key_code)
  174.     if @self_trigger.call(key_code)
  175.       return true
  176.     end
  177.     if key_code == C
  178.       return Mouse.trigger?(Mouse::LEFT)
  179.     elsif key_code == B
  180.       return Mouse.trigger?(Mouse::RIGHT)
  181.     else
  182.       return @self_trigger.call(key_code)
  183.     end
  184.   end
  185.   def self.repeat?(key_code)
  186.     if @self_repeat.call(key_code)
  187.       return true
  188.     end
  189.     if key_code == C
  190.       return Mouse.repeat?(Mouse::LEFT)
  191.     elsif key_code == B
  192.       return Mouse.repeat?(Mouse::RIGHT)
  193.     else
  194.       return @self_repeat.call(key_code)
  195.     end
  196.   end
  197. end
  198. class Window_Selectable
  199.   if @self_alias == nil
  200.     alias self_update update
  201.     @self_alias = true
  202.   end
  203.   def update
  204.     #self.cursor_rect.empty
  205.     self_update
  206.     if self.active and @item_max > 0
  207.       index_var = @index
  208.       tp_index = @index
  209.       mouse_x, mouse_y = Mouse.get_mouse_pos
  210.       mouse_not_in_rect = true
  211.       for i in 0...@item_max
  212.         @index = i
  213.         update_cursor_rect
  214.         top_x = self.cursor_rect.x + self.x + 16
  215.         top_y = self.cursor_rect.y + self.y + 16
  216.         bottom_x = top_x + self.cursor_rect.width
  217.         bottom_y = top_y + self.cursor_rect.height
  218.         if (mouse_x > top_x) and (mouse_y > top_y) and
  219.            (mouse_x < bottom_x) and (mouse_y < bottom_y)
  220.           mouse_not_in_rect = false
  221.           if tp_index != @index
  222.             tp_index = @index
  223.             $game_system.se_play($data_system.cursor_se)
  224.           end
  225.           break
  226.         end
  227.       end
  228.       if mouse_not_in_rect
  229.         @index = index_var
  230.         update_cursor_rect
  231.         Mouse.click_lock
  232.       else
  233.         Mouse.click_unlock               
  234.       end
  235.     end
  236.   end
  237. end
  238. class Window_NameInput
  239.   if @self_alias == nil
  240.     alias self_update update
  241.     @self_alias = true
  242.   end
  243.   def update
  244.     #self.cursor_rect.empty
  245.     self_update
  246.     if self.active
  247.       index_var = @index
  248.       mouse_x, mouse_y = Mouse.get_mouse_pos
  249.       mouse_not_in_rect = true
  250.       for i in (0...CHARACTER_TABLE.size).to_a.push(180)
  251.         @index = i
  252.         update_cursor_rect
  253.         top_x = self.cursor_rect.x + self.x + 16
  254.         top_y = self.cursor_rect.y + self.y + 16
  255.         bottom_x = top_x + self.cursor_rect.width
  256.         bottom_y = top_y + self.cursor_rect.height
  257.         #
  258.         if (mouse_x > top_x) and (mouse_y > top_y) and
  259.            (mouse_x < bottom_x) and (mouse_y < bottom_y)
  260.           mouse_not_in_rect = false
  261.           break
  262.         end
  263.       end
  264.       if mouse_not_in_rect
  265.         @index = index_var
  266.         update_cursor_rect
  267.         Mouse.click_lock
  268.       else
  269.         Mouse.click_unlock
  270.       end
  271.     end
  272.   end
  273. end
  274. class Window_InputNumber
  275.   if @self_alias == nil
  276.     alias self_update update
  277.     @self_alias = true
  278.   end
  279.   def update
  280.     #self.cursor_rect.empty
  281.     self_update
  282.     mouse_x, mouse_y = Mouse.get_mouse_pos
  283.     if self.active and @digits_max > 0
  284.       index_var = @index
  285.       mouse_not_in_rect = true
  286.       for i in 0...@digits_max
  287.         @index = i
  288.         update_cursor_rect
  289.         top_x = self.cursor_rect.x + self.x + 16
  290.         bottom_x = top_x + self.cursor_rect.width
  291.         #
  292.         if (mouse_x > top_x) and (mouse_x < bottom_x)
  293.           mouse_not_in_rect = false
  294.           break
  295.         end
  296.       end
  297.       if mouse_not_in_rect
  298.         @index = index_var
  299.         update_cursor_rect
  300.         Mouse.click_lock
  301.       else
  302.         Mouse.click_unlock
  303.       end
  304.     end
  305.     if @last_mouse_y == nil
  306.       @last_mouse_y = mouse_y
  307.     end
  308.     check_pos = (@last_mouse_y - mouse_y).abs
  309.     if check_pos > 10
  310.       $game_system.se_play($data_system.cursor_se)
  311.       place = 10 ** (@digits_max - 1 - @index)
  312.       n = @number / place % 10
  313.       @number -= n * place
  314.       n = (n + 1) % 10 if mouse_y < @last_mouse_y
  315.       n = (n + 9) % 10 if mouse_y > @last_mouse_y
  316.       @number += n * place
  317.       refresh
  318.       @last_mouse_y = mouse_y
  319.     end
  320.   end
  321. end
  322. class Scene_File
  323.   if @self_alias == nil
  324.     alias self_update update
  325.     @self_alias = true
  326.   end
  327.   def update
  328.     mouse_x, mouse_y = Mouse.get_mouse_pos
  329.     Mouse.click_lock
  330.     idx = 0
  331.     for i in @savefile_windows
  332.       top_x = i.x + 16
  333.       top_y = i.y + 16
  334.       bottom_x = top_x + i.width
  335.       bottom_y = top_y + i.height
  336.       if (mouse_x > top_x) and (mouse_y > top_y) and
  337.          (mouse_x < bottom_x) and (mouse_y < bottom_y)
  338.         i.selected = true
  339.         if @file_index != idx
  340.           @file_index = idx
  341.           $game_system.se_play($data_system.cursor_se)
  342.         end            
  343.         Mouse.click_unlock
  344.       else
  345.         i.selected = false
  346.       end
  347.       idx += 1
  348.     end
  349.     self_update
  350.   end
  351. end
  352. class Arrow_Enemy
  353.   if @self_alias == nil
  354.     alias self_update update
  355.     @self_alias = true
  356.   end
  357.   def update
  358.     mouse_x, mouse_y = Mouse.get_mouse_pos
  359.     idx = 0
  360.     for i in $game_troop.enemies do
  361.       if i.exist?
  362.         top_x = i.screen_x - self.ox
  363.         top_y = i.screen_y - self.oy
  364.         bottom_x = top_x + self.src_rect.width
  365.         bottom_y = top_y + self.src_rect.height
  366.         if (mouse_x > top_x - $敌人选框扩大) and (mouse_y > top_y - $敌人选框扩大) and
  367.            (mouse_x < bottom_x + $敌人选框扩大) and (mouse_y < bottom_y + $敌人选框扩大)
  368.           if @index != idx
  369.             $game_system.se_play($data_system.cursor_se)
  370.             @index = idx
  371.           end
  372.         end
  373.       end
  374.       idx += 1
  375.     end
  376.     self_update
  377.   end
  378. end
  379. class Arrow_Actor
  380.   if @self_alias == nil
  381.     alias self_update update
  382.     @self_alias = true
  383.   end
  384.   def update
  385.     mouse_x, mouse_y = Mouse.get_mouse_pos
  386.     idx = 0
  387.     for i in $game_party.actors do
  388.       if i.exist?
  389.         top_x = i.screen_x - self.ox
  390.         top_y = i.screen_y - self.oy
  391.         bottom_x = top_x + self.src_rect.width
  392.         bottom_y = top_y + self.src_rect.height
  393.         if (mouse_x > top_x - $角色选框扩大) and (mouse_y > top_y - $角色选框扩大) and
  394.            (mouse_x < bottom_x + $角色选框扩大) and (mouse_y < bottom_y + $角色选框扩大)
  395.           if @index != idx
  396.             $game_system.se_play($data_system.cursor_se)
  397.             @index = idx
  398.           end
  399.         end
  400.       end
  401.       idx += 1
  402.     end
  403.     self_update
  404.   end
  405. end
  406. class Game_Player
  407.   if @self_alias == nil
  408.     alias self_update update
  409.     @self_alias = true
  410.   end
  411.   def update
  412.     mouse_x, mouse_y = Mouse.get_mouse_pos

  413.     if @last_move_x == nil
  414.       @last_move_x = false
  415.     end
  416.     if Mouse.press?(Mouse::LEFT)
  417.       last_moving = moving?
  418.       last_direction = @direction
  419.       unless moving? or $game_system.map_interpreter.running? or
  420.              @move_route_forcing or $game_temp.message_window_showing
  421.         last_x = @x
  422.         if @last_move_x
  423.           @last_move_x = false
  424.         elsif mouse_x > screen_x + 16
  425.           move_right
  426.         elsif mouse_x < screen_x - 16
  427.           move_left
  428.         end
  429.         last_y = @y
  430.         if last_x != @x
  431.           @last_move_x = true
  432.         elsif mouse_y > screen_y
  433.           move_down
  434.         elsif mouse_y < screen_y - 32
  435.           move_up
  436.         end
  437.         if last_y != @y
  438.           @last_move_x = false
  439.         elsif not @last_move_x
  440.           case last_direction
  441.           when 2
  442.             turn_down
  443.           when 4
  444.             turn_left
  445.           when 6
  446.             turn_right
  447.           when 8
  448.             turn_up
  449.           end
  450.         end
  451.       end
  452.     end
  453.     self_update
  454.   end
  455. end
  456. Mouse.init
  457. END { Mouse.exit }




  458. #==============================================================================
  459. # 本脚本来自http://rpg.blue/web/,使用和转载请保留此信息
  460. #==============================================================================
复制代码

Lv1.梦旅人

垃圾死人

梦石
0
星屑
50
在线时间
285 小时
注册时间
2009-1-27
帖子
2420

贵宾

2
发表于 2010-12-26 12:18:38 | 只看该作者
@mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/cursor1.png')

这一行也就是第38行
最后那个cursor1.png改成你想要的图标名就行
记住那个图标要放在Icons文件夹里
最后.记得去认可我


无心孤云于2010-12-26 12:47补充以下内容:
以上修改方法经我测试后无误
楼主你估计是没有你要的那个"默认的"素材把?
别告诉我你要的默认的是win XP里的这个箭头....
那你得自己做这个素材
如果不是.只是RMXP里的那把小剑的话
你就得把001-Weapon01文件copy过去

点评

我要默认的,不是改成自己的 默认的就是不改之前的小箭头 你这个我知道...不要这个,,,,改完问题依旧  发表于 2010-12-26 12:40
努力努力再努力
回复 支持 反对

使用道具 举报

Lv4.逐梦者

梦石
0
星屑
7981
在线时间
1183 小时
注册时间
2007-7-29
帖子
2055
3
发表于 2010-12-26 13:38:15 | 只看该作者
把$ShowCursor.call(0)改成$ShowCursor.call(1)
然后注释掉……
@mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/cursor1.png')

明明就写着很大个showcursor的说……
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-9-28 05:28

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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