幻想森林

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 2380|回复: 6

[RMVX] 请教前辈 RPG游戏能不能用鼠标操作?

[复制链接]

2

主题

2

帖子

24

积分

②入门

积分
24
发表于 2006-6-22 11:49:24 | 显示全部楼层 |阅读模式
上下左右键操作比较麻烦,用鼠标就可以灵活一点
回复

使用道具 举报

122

主题

4962

帖子

74

积分

超级版主

Rank: 8Rank: 8

积分
74

声命组银赏

QQ
发表于 2006-6-22 11:51:06 | 显示全部楼层
有鼠标操作脚本
回复 支持 反对

使用道具 举报

墮天使路 该用户已被删除
发表于 2006-6-22 21:35:27 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
回复 支持 反对

使用道具 举报

218

主题

1万

帖子

10万

积分

⑧专业

赋予你第五自由

积分
108021
发表于 2006-6-22 22:53:33 | 显示全部楼层
当然鸡肋,因为RMXP本来是不准备支持鼠标的..硬要加上去反而让人觉得讨厌啊这功能

第 五 自 由 -   5th  Freedom   -

回复 支持 反对

使用道具 举报

91

主题

3188

帖子

83986万

积分

荣誉群

传说中的Bunny大神~!

积分
839861514
QQ
发表于 2006-6-22 23:01:04 | 显示全部楼层
感觉非常的鸡肋,我自己游戏里都把这个功能去除掉了。。。 [s:5]
其他所有的Bunny神都素我的部下XD~ 小教程范例收集 Orz感谢邪恶萝卜联盟!!!(原因自己去猜)
回复 支持 反对

使用道具 举报

30

主题

477

帖子

5219

积分

⑦老手

积分
5219
发表于 2006-6-23 08:39:34 | 显示全部楼层
鼠标响应事件要怎么做哇?如果用鼠标的话,应该还是要全屏玩比较方便。
回复 支持 反对

使用道具 举报

0

主题

1

帖子

13

积分

②入门

积分
13
发表于 2006-11-27 14:40:22 | 显示全部楼层
给你个脚本
但是BUG很多~~~
不,是容易冲突
脚本内容:
  1. #=================以下两个用来调整战斗时的手感问题,可以自己试试。
  2. $敌人选框扩大 = 20
  3. $角色选框扩大 = 30
  4. #==============================================================================
  5. # API调用
  6. #==============================================================================
  7. $ShowCursor = Win32API.new("user32", "ShowCursor", 'i', 'l')
  8. $GetCursorPos = Win32API.new("user32", "GetCursorPos", 'p', 'i')
  9. $ScreenToClient = Win32API.new("user32", "ScreenToClient", 'ip', 'i')
  10. $GetActiveWindow = Win32API.new("user32", "GetActiveWindow", nil, 'l')
  11. $Window_HWND = $GetActiveWindow.call
  12. $GetKeyState = Win32API.new("user32", "GetKeyState", 'i', 'i')
  13. #$FindWindow = Win32API.new("user32", "FindWindow", 'pp', 'i')
  14. #$HookStart  = Win32API.new("mouse_hook.dll", "HookStart", 'i', nil)
  15. #$HookEnd  = Win32API.new("mouse_hook.dll", "HookEnd", nil, nil)
  16. #$GetMouseStatus  = Win32API.new("mouse_hook.dll", "GetMouseStatus", 'i', 'i')
  17. #$Window_HWND = $FindWindow.call(nil, 'mousetry')
  18. module Mouse  
  19.   LEFT = 0x01
  20.   RIGHT = 0x02
  21.   def self.init(sprite = nil)
  22. #   $HookStart.call($Window_HWND)
  23.     $ShowCursor.call(0)
  24.    
  25.     @show_cursor = false
  26.    
  27.     @mouse_sprite = Sprite.new
  28.     @mouse_sprite.z = 99999
  29.     @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/001-Weapon01.png')
  30.     #@mouse_sprite.bitmap.fill_rect(Rect.new(0, 0, 32, 32), Color.new(0, 0, 0))
  31.     @left_press = false
  32.     @right_press = false
  33.     @left_trigger = false
  34.     @right_trigger = false
  35.     @left_repeat = false
  36.     @right_repeat = false
  37.     @click_lock = false
  38.    
  39.     update
  40.   end
  41.   def self.exit
  42.     @mouse_sprite.bitmap.dispose
  43.     @mouse_sprite.dispose
  44.     @show_cursor = true
  45. #    $HookEnd.call
  46.     $ShowCursor.call(1)
  47.   end
  48.   def self.mouse_debug
  49.     return @mouse_debug.bitmap
  50.   end
  51.   def self.update
  52.     left_down = $GetKeyState.call(0x01)
  53.     right_down = $GetKeyState.call(0x02)
  54.    
  55.     @click_lock = false
  56.     mouse_x, mouse_y = self.get_mouse_pos
  57.     if @mouse_sprite != nil
  58.       @mouse_sprite.x = mouse_x
  59.       @mouse_sprite.y = mouse_y
  60.     end
  61.     if left_down[7] == 1
  62.       @left_repeat = (not @left_repeat)
  63.       @left_trigger = (not @left_press)
  64.       @left_press = true
  65.     else
  66.       @left_press = false
  67.       @left_trigger = false
  68.       @left_repeat = false
  69.     end
  70.     if right_down[7] == 1
  71.       @right_repeat = (not @right_repeat)
  72.       @right_trigger = (not @right_press)
  73.       @right_press = true
  74.     else
  75.       @right_press = false
  76.       @right_trigger = false
  77.       @right_repeat = false
  78.     end
  79.   end
  80.   def self.get_mouse_pos
  81.     point_var = [0, 0].pack('ll')
  82.     if $GetCursorPos.call(point_var) != 0
  83.       if $ScreenToClient.call($Window_HWND, point_var) != 0
  84.         x, y = point_var.unpack('ll')
  85.         if (x < 0) or (x > 10000) then x = 0 end
  86.         if (y < 0) or (y > 10000) then y = 0 end
  87.         if x > 640 then x = 640 end
  88.         if y > 480 then y = 480 end
  89.         return x, y
  90.       else
  91.         return 0, 0
  92.       end
  93.     else
  94.       return 0, 0
  95.     end
  96.   end
  97.   def self.press?(mouse_code)
  98.     if mouse_code == LEFT
  99.       if @click_lock
  100.         return false
  101.       else
  102.         return @left_press
  103.       end
  104.     elsif mouse_code == RIGHT
  105.       return @right_press
  106.     else
  107.       return false
  108.     end
  109.   end
  110.   def self.trigger?(mouse_code)
  111.     if mouse_code == LEFT
  112.       if @click_lock
  113.         return false
  114.       else
  115.         return @left_trigger
  116.       end
  117.     elsif mouse_code == RIGHT
  118.       return @right_trigger
  119.     else
  120.       return false
  121.     end
  122.   end
  123.   def self.repeat?(mouse_code)
  124.     if mouse_code == LEFT
  125.       if @click_lock
  126.         return false
  127.       else
  128.         return @left_repeat
  129.       end
  130.     elsif mouse_code == RIGHT
  131.       return @right_repeat
  132.     else
  133.       return false
  134.     end
  135.   end
  136.   def self.click_lock?
  137.     return @click_lock
  138.   end
  139.   def self.click_lock
  140.     @click_lock = true
  141.   end
  142.   def self.click_unlock
  143.     @click_lock = false
  144.   end
  145. end
  146. module Input
  147.   if @self_update == nil
  148.     @self_update = method('update')
  149.     @self_press = method('press?')
  150.     @self_trigger = method('trigger?')
  151.     @self_repeat = method('repeat?')
  152.   end
  153.   def self.update
  154.     @self_update.call
  155.     Mouse.update
  156.   end
  157.   def self.press?(key_code)
  158.     if @self_press.call(key_code)
  159.       return true
  160.     end
  161.     if key_code == C
  162.       return Mouse.press?(Mouse::LEFT)
  163.     elsif key_code == B
  164.       return Mouse.press?(Mouse::RIGHT)
  165.     else
  166.       return @self_press.call(key_code)
  167.     end
  168.   end
  169.   def self.trigger?(key_code)
  170.     if @self_trigger.call(key_code)
  171.       return true
  172.     end
  173.     if key_code == C
  174.       return Mouse.trigger?(Mouse::LEFT)
  175.     elsif key_code == B
  176.       return Mouse.trigger?(Mouse::RIGHT)
  177.     else
  178.       return @self_trigger.call(key_code)
  179.     end
  180.   end
  181.   def self.repeat?(key_code)
  182.     if @self_repeat.call(key_code)
  183.       return true
  184.     end
  185.     if key_code == C
  186.       return Mouse.repeat?(Mouse::LEFT)
  187.     elsif key_code == B
  188.       return Mouse.repeat?(Mouse::RIGHT)
  189.     else
  190.       return @self_repeat.call(key_code)
  191.     end
  192.   end
  193. end
  194. class Window_Selectable
  195.   if @self_alias == nil
  196.     alias self_update update
  197.     @self_alias = true
  198.   end
  199.   def update
  200.     #self.cursor_rect.empty
  201.     self_update
  202.     if self.active and @item_max > 0
  203.       index_var = @index
  204.       tp_index = @index
  205.       mouse_x, mouse_y = Mouse.get_mouse_pos
  206.       mouse_not_in_rect = true
  207.       for i in 0...@item_max
  208.         @index = i
  209.         update_cursor_rect
  210.         top_x = self.cursor_rect.x + self.x + 16
  211.         top_y = self.cursor_rect.y + self.y + 16
  212.         bottom_x = top_x + self.cursor_rect.width
  213.         bottom_y = top_y + self.cursor_rect.height
  214.         if (mouse_x > top_x) and (mouse_y > top_y) and
  215.            (mouse_x < bottom_x) and (mouse_y < bottom_y)
  216.           mouse_not_in_rect = false
  217.           if tp_index != @index
  218.             tp_index = @index
  219.             $game_system.se_play($data_system.cursor_se)
  220.           end
  221.           break
  222.         end
  223.       end
  224.       if mouse_not_in_rect
  225.         @index = index_var
  226.         update_cursor_rect
  227.         Mouse.click_lock
  228.       else
  229.         Mouse.click_unlock               
  230.       end
  231.     end
  232.   end
  233. end
  234. class Window_NameInput
  235.   if @self_alias == nil
  236.     alias self_update update
  237.     @self_alias = true
  238.   end
  239.   def update
  240.     #self.cursor_rect.empty
  241.     self_update
  242.     if self.active
  243.       index_var = @index
  244.       mouse_x, mouse_y = Mouse.get_mouse_pos
  245.       mouse_not_in_rect = true
  246.       for i in (0...CHARACTER_TABLE.size).to_a.push(180)
  247.         @index = i
  248.         update_cursor_rect
  249.         top_x = self.cursor_rect.x + self.x + 16
  250.         top_y = self.cursor_rect.y + self.y + 16
  251.         bottom_x = top_x + self.cursor_rect.width
  252.         bottom_y = top_y + self.cursor_rect.height
  253.         #
  254.         if (mouse_x > top_x) and (mouse_y > top_y) and
  255.            (mouse_x < bottom_x) and (mouse_y < bottom_y)
  256.           mouse_not_in_rect = false
  257.           break
  258.         end
  259.       end
  260.       if mouse_not_in_rect
  261.         @index = index_var
  262.         update_cursor_rect
  263.         Mouse.click_lock
  264.       else
  265.         Mouse.click_unlock
  266.       end
  267.     end
  268.   end
  269. end
  270. class Window_InputNumber
  271.   if @self_alias == nil
  272.     alias self_update update
  273.     @self_alias = true
  274.   end
  275.   def update
  276.     #self.cursor_rect.empty
  277.     self_update
  278.     mouse_x, mouse_y = Mouse.get_mouse_pos
  279.     if self.active and @digits_max > 0
  280.       index_var = @index
  281.       mouse_not_in_rect = true
  282.       for i in 0...@digits_max
  283.         @index = i
  284.         update_cursor_rect
  285.         top_x = self.cursor_rect.x + self.x + 16
  286.         bottom_x = top_x + self.cursor_rect.width
  287.         #
  288.         if (mouse_x > top_x) and (mouse_x < bottom_x)
  289.           mouse_not_in_rect = false
  290.           break
  291.         end
  292.       end
  293.       if mouse_not_in_rect
  294.         @index = index_var
  295.         update_cursor_rect
  296.         Mouse.click_lock
  297.       else
  298.         Mouse.click_unlock
  299.       end
  300.     end
  301.     if @last_mouse_y == nil
  302.       @last_mouse_y = mouse_y
  303.     end
  304.     check_pos = (@last_mouse_y - mouse_y).abs
  305.     if check_pos > 10
  306.       $game_system.se_play($data_system.cursor_se)
  307.       place = 10 ** (@digits_max - 1 - @index)
  308.       n = @number / place % 10
  309.       @number -= n * place
  310.       n = (n + 1) % 10 if mouse_y < @last_mouse_y
  311.       n = (n + 9) % 10 if mouse_y > @last_mouse_y
  312.       @number += n * place
  313.       refresh
  314.       @last_mouse_y = mouse_y
  315.     end
  316.   end
  317. end
  318. class Scene_File
  319.   if @self_alias == nil
  320.     alias self_update update
  321.     @self_alias = true
  322.   end
  323.   def update
  324.     mouse_x, mouse_y = Mouse.get_mouse_pos
  325.     Mouse.click_lock
  326.     idx = 0
  327.     for i in @savefile_windows
  328.       top_x = i.x + 16
  329.       top_y = i.y + 16
  330.       bottom_x = top_x + i.width
  331.       bottom_y = top_y + i.height
  332.       if (mouse_x > top_x) and (mouse_y > top_y) and
  333.          (mouse_x < bottom_x) and (mouse_y < bottom_y)
  334.         i.selected = true
  335.         if @file_index != idx
  336.           @file_index = idx
  337.           $game_system.se_play($data_system.cursor_se)
  338.         end            
  339.         Mouse.click_unlock
  340.       else
  341.         i.selected = false
  342.       end
  343.       idx += 1
  344.     end
  345.     self_update
  346.   end
  347. end
  348. class Arrow_Enemy
  349.   if @self_alias == nil
  350.     alias self_update update
  351.     @self_alias = true
  352.   end
  353.   def update
  354.     mouse_x, mouse_y = Mouse.get_mouse_pos
  355.     idx = 0
  356.     for i in $game_troop.enemies do
  357.       if i.exist?
  358.         top_x = i.screen_x - self.ox
  359.         top_y = i.screen_y - self.oy
  360.         bottom_x = top_x + self.src_rect.width
  361.         bottom_y = top_y + self.src_rect.height
  362.         if (mouse_x > top_x - $敌人选框扩大) and (mouse_y > top_y - $敌人选框扩大) and
  363.            (mouse_x < bottom_x + $敌人选框扩大) and (mouse_y < bottom_y + $敌人选框扩大)
  364.           if @index != idx
  365.             $game_system.se_play($data_system.cursor_se)
  366.             @index = idx
  367.           end
  368.         end
  369.       end
  370.       idx += 1
  371.     end
  372.     self_update
  373.   end
  374. end
  375. class Arrow_Actor
  376.   if @self_alias == nil
  377.     alias self_update update
  378.     @self_alias = true
  379.   end
  380.   def update
  381.     mouse_x, mouse_y = Mouse.get_mouse_pos
  382.     idx = 0
  383.     for i in $game_party.actors do
  384.       if i.exist?
  385.         top_x = i.screen_x - self.ox
  386.         top_y = i.screen_y - self.oy
  387.         bottom_x = top_x + self.src_rect.width
  388.         bottom_y = top_y + self.src_rect.height
  389.         if (mouse_x > top_x - $角色选框扩大) and (mouse_y > top_y - $角色选框扩大) and
  390.            (mouse_x < bottom_x + $角色选框扩大) and (mouse_y < bottom_y + $角色选框扩大)
  391.           if @index != idx
  392.             $game_system.se_play($data_system.cursor_se)
  393.             @index = idx
  394.           end
  395.         end
  396.       end
  397.       idx += 1
  398.     end
  399.     self_update
  400.   end
  401. end
  402. class Game_Player
  403.   if @self_alias == nil
  404.     alias self_update update
  405.     @self_alias = true
  406.   end
  407.   def update
  408.     mouse_x, mouse_y = Mouse.get_mouse_pos
  409.     if @last_move_x == nil
  410.       @last_move_x = false
  411.     end
  412.     if Mouse.press?(Mouse::LEFT)
  413.       last_moving = moving?
  414.       last_direction = @direction
  415.       unless moving? or $game_system.map_interpreter.running? or
  416.              @move_route_forcing or $game_temp.message_window_showing
  417.         last_x = @x
  418.         if @last_move_x
  419.           @last_move_x = false
  420.         elsif mouse_x > screen_x + 16
  421.           move_right
  422.         elsif mouse_x < screen_x - 16
  423.           move_left
  424.         end
  425.         last_y = @y
  426.         if last_x != @x
  427.           @last_move_x = true
  428.         elsif mouse_y > screen_y
  429.           move_down
  430.         elsif mouse_y < screen_y - 32
  431.           move_up
  432.         end
  433.         if last_y != @y
  434.           @last_move_x = false
  435.         elsif not @last_move_x
  436.           case last_direction
  437.           when 2
  438.             turn_down
  439.           when 4
  440.             turn_left
  441.           when 6
  442.             turn_right
  443.           when 8
  444.             turn_up
  445.           end
  446.         end
  447.       end
  448.     end
  449.     self_update
  450.   end
  451. end
  452. Mouse.init
  453. END { Mouse.exit }
复制代码
[s:5]
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|幻想森林

GMT+8, 2025-6-27 21:11 , Processed in 0.012327 second(s), 22 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

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