幻想森林

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

[RM2K&2K3] rmxp使了鼠标整和脚本,在任何窗口鼠标都能控制光标,就在

[复制链接]

9

主题

26

帖子

237

积分

③业余

积分
237
发表于 2009-2-28 15:25:44 | 显示全部楼层 |阅读模式
rmxp使了鼠标整和脚本,在任何窗口鼠标都能控制光标,就在新创建的窗口不能为什么?啊

谢谢 需要在新创建的窗口做什么呢》

我使的一个人的创建角色脚本 在创建角色时 不能用鼠标控制光标 其他游戏时都能用鼠标控制1~~要在这个窗口做点什么吗?还是在鼠标脚本中呢?
回复

使用道具 举报

9

主题

26

帖子

237

积分

③业余

积分
237
 楼主| 发表于 2009-2-28 15:35:38 | 显示全部楼层

Re:rmxp使了鼠标整和脚本,在任何窗口鼠标都能控制光标,就在

鼠标脚本
  1. #==============================================================================
  2. # ■ 完整鼠标系统(八方向)
  3. #------------------------------------------------------------------------------
  4. #  使用时务必配合专用寻路算法
  5. #   By whbm
  6. #==============================================================================
  7. #下面做一下介绍与使用说明:
  8. #    在屏幕上单击鼠标的时候,会自动进行寻路,这里为了速度更快并且为了进行迷
  9. #宫时的难度寻路被限定在当时的屏幕内部。(否则玩家直接点到终点,呵呵....知道
  10. #后果了吧)
  11. #    在角色移动过程中再次单击鼠标(即双击)并在单击第二次鼠标的时候不松手,
  12. #角色将会跟随鼠标方向移动。(这个应该好理解,不用多说吧)当角色贴着欲被启动
  13. #的事件的时候,单击NPC即可启动事件。若未贴着,将会产生自动寻路到NPC附近的某
  14. #点,那时在单击NPC即可。
  15. #    当鼠标停在某些事件上时候会发现有不同的图标,设置方法为:宝箱事件请在事
  16. #件的执行内容中添加 注释,注释内容为 Item 注意大小写。NPC事件请在事件的执行
  17. #内容中添加 注释注释内容为 NPC 注意大小写。若不箱改变某事件的图标,则不要写
  18. #那两个注释。
  19. #    当把脚本转到您工程的时候千万别忘了那个寻路用的脚本。
  20. #==============================================================================
  21. class Game_Event
  22.   attr_accessor :flag
  23. end
  24. #==============================================================================
  25. # ■ Game_Map
  26. #------------------------------------------------------------------------------
  27. #  处理地图的类。包含卷动以及可以通行的判断功能。
  28. # 本类的实例请参考 $game_map 。
  29. #==============================================================================
  30. class Game_Map
  31.   def show_rate(event)
  32.     return 1
  33.   end
  34.   #--------------------------------------------------------------------------
  35.   # ● 检查鼠标处是否有自定义的事件并返回类型
  36.   #--------------------------------------------------------------------------
  37.   def check_event_custom(mouse_x, mouse_y)
  38.     for event in $game_map.events.values #循环所有事件检查
  39.       rate =  show_rate(event)
  40.       event_width = (RPG::Cache.character(event.character_name,event.character_hue).width / $c3_每一步的帧数) * rate
  41.       event_height = (RPG::Cache.character(event.character_name,event.character_hue).height / 8) * rate
  42.       if mouse_x > event.screen_x - event_width / 2 and mouse_x < event.screen_x + event_width / 2 and mouse_y + 32 > event.screen_y + 32 - event_height and mouse_y + 32 < event.screen_y + 32
  43.         for i in 0...event.list.size
  44.           if event.list[i].parameters[0] == "Item" #类型判断
  45.             event.flag = 1
  46.           elsif event.list[i].parameters[0] == "Npc" #类型判断
  47.             event.flag = 2
  48.           else
  49.             event.flag = 0 if $game_player.get_mouse_sta != 2 #无标志
  50.           end
  51.           return event.flag #返回事件类型标志
  52.         end
  53.       end
  54.     end
  55.     return 0 if $game_player.get_mouse_sta != 2 #如果不是在跟随鼠标状态,则返回无标志
  56.     return $mouse_icon_id #使鼠标图不变化
  57.   end
  58.   #--------------------------------------------------------------------------
  59.   # ● 检查鼠标处是否有事件可以开启
  60.   #--------------------------------------------------------------------------
  61.   def check_event_custom_start(mouse_x, mouse_y)
  62.     for event in $game_map.events.values #循环所有事件检查
  63.       #事件角色图片宽度、高度
  64.       rate =  show_rate(event)
  65.       event_width = (RPG::Cache.character(event.character_name,event.character_hue).width / $c3_每一步的帧数) * rate
  66.       event_height = (RPG::Cache.character(event.character_name,event.character_hue).height / 8) * rate
  67.       #判断是否鼠标在事件上
  68.       if mouse_x > event.screen_x - event_width / 2 and mouse_x < event.screen_x + event_width / 2 and mouse_y + 32 > event.screen_y + 32 - event_height and mouse_y + 32 < event.screen_y + 32
  69.         way_x = $game_player.x - event.x
  70.         way_y = $game_player.y - event.y
  71.         if [1,0,-1].include?($game_player.x-event.x) and [1,0,-1].include?($game_player.y-event.y)
  72.           for i in 0...event.list.size
  73.             if ["Item","Npc"].include?(event.list[i].parameters[0]) #当事件属于自定义事件
  74.               #判断主角朝向
  75.               if way_x == -1
  76.                 p_direction = 3 if way_y == -1
  77.                 p_direction = 6 if way_y == 0
  78.                 p_direction = 9 if way_y == 1
  79.               elsif way_x == 0
  80.                 p_direction = 2 if way_y == -1
  81.                 p_direction = 8 if way_y == 1
  82.               else
  83.                 p_direction = 1 if way_y == -1
  84.                 p_direction = 4 if way_y == 0
  85.                 p_direction = 7 if way_y == 1
  86.               end
  87.               event.start #开启事件
  88.               return 1, p_direction #返回即将开启事件以及角色朝向
  89.             end
  90.           end
  91.         end
  92.       end
  93.     end
  94.     return 0, 5 #返回不会开启事件以及角色朝向不变
  95.   end
  96.   #--------------------------------------------------------------------------
  97.   # ● 检查鼠标处是否存在自定义事件 for 寻路
  98.   #--------------------------------------------------------------------------
  99.   def check_event_custom_exist(mouse_x, mouse_y)
  100.     for event in $game_map.events.values #循环所有事件检查
  101.       #事件角色图片宽度、高度
  102.       rate =  show_rate(event)
  103.       event_width = (RPG::Cache.character(event.character_name,event.character_hue).width / $c3_每一步的帧数) * rate
  104.       event_height = (RPG::Cache.character(event.character_name,event.character_hue).height / 8) * rate
  105.       if mouse_x > event.screen_x - event_width / 2 and mouse_x < event.screen_x + event_width / 2 and mouse_y + 32 > event.screen_y + 32 - event_height and mouse_y + 32 < event.screen_y + 32
  106.         for i in 0...event.list.size
  107.           return 1, event if ["Item", "Npc"].include?(event.list[i].parameters[0]) #返回存在自定义事件以及事件体
  108.         end
  109.       end
  110.     end
  111.     return 0, event #返回不存在自定义事件,以及事件体
  112.   end
  113. end
  114. #=================以下两个用来调整战斗时的手感问题,可以自己试试。
  115. $敌人选框扩大 = 20
  116. $角色选框扩大 = 30
  117. #==============================================================================
  118. # ● API调用
  119. #==============================================================================
  120. $ShowCursor = Win32API.new("user32", "ShowCursor", 'i', 'l')
  121. $GetCursorPos = Win32API.new("user32", "GetCursorPos", 'p', 'i')
  122. $ScreenToClient = Win32API.new("user32", "ScreenToClient", 'ip', 'i')
  123. $GetActiveWindow = Win32API.new("user32", "GetActiveWindow", nil, 'l')
  124. $Window_HWND = $GetActiveWindow.call
  125. $GetKeyState = Win32API.new("user32", "GetKeyState", 'i', 'i')
  126. module Mouse  
  127. LEFT = 0x01
  128. RIGHT = 0x02
  129. def self.init(sprite = nil)
  130.    $ShowCursor.call(0)
  131.    
  132.    @show_cursor = false
  133.    
  134.    @mouse_sprite = Sprite.new
  135.    @mouse_sprite.z = 99999
  136.    @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/木剑')
  137.    @left_press = false
  138.    @right_press = false
  139.    @left_trigger = false
  140.    @right_trigger = false
  141.    @left_repeat = false
  142.    @right_repeat = false
  143.    @click_lock = false
  144.    
  145.    update
  146. end
  147. def self.exit
  148.    @mouse_sprite.bitmap.dispose
  149.    @mouse_sprite.dispose
  150.    @show_cursor = true
  151.    $ShowCursor.call(1)
  152. end
  153. def self.mouse_debug
  154.    return @mouse_debug.bitmap
  155. end
  156. def self.update
  157.    left_down = $GetKeyState.call(0x01)
  158.    right_down = $GetKeyState.call(0x02)
  159.    if Graphics.frame_count * 3 / Graphics.frame_rate != @total_sec
  160.      @total_sec = Graphics.frame_count * 3 / Graphics.frame_rate
  161.      @a = !@a
  162.    end
  163.    if $scene.is_a?(Scene_Map) == false
  164.      $mouse_icon_id = 0
  165.    end
  166.    if $mouse_icon_id != $mouse_icon_id_last
  167.      case $mouse_icon_id
  168.      when 1
  169.        if @a
  170.          @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/GetItem1')
  171.        else
  172.          @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/GetItem2')
  173.        end
  174.      when 2
  175.        if @a
  176.          @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/TalkTo1')
  177.        else
  178.          @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/TalkTo2')
  179.        end
  180.      when 11
  181.        @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/Mouse_LOWER_LEFT')
  182.      when 12
  183.        @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/Mouse_DOWN')
  184.      when 13
  185.        @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/Mouse_LOWER_RIGHT')
  186.      when 14
  187.        @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/Mouse_LEFT')
  188.      when 16
  189.        @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/Mouse_RIGHT')
  190.      when 17
  191.        @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/Mouse_UPPER_LEFT')
  192.      when 18
  193.        @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/Mouse_UP')
  194.      when 19
  195.        @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/Mouse_UPPER_RIGHT')
  196.      when 0
  197.        @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/木剑')
  198.      end
  199.      $mouse_icon_id_last = $mouse_icon_id
  200.    end
  201.    @click_lock = false
  202.    mouse_x, mouse_y = self.get_mouse_pos
  203.    if @mouse_sprite != nil
  204.      @mouse_sprite.x = mouse_x
  205.      @mouse_sprite.y = mouse_y
  206.    end
  207.    if left_down[7] == 1
  208.      @left_repeat = (not @left_repeat)
  209.      @left_trigger = (not @left_press)
  210.      @left_press = true
  211.    else
  212.      @left_press = false
  213.      @left_trigger = false
  214.      @left_repeat = false
  215.    end
  216.    if right_down[7] == 1
  217.      @right_repeat = (not @right_repeat)
  218.      @right_trigger = (not @right_press)
  219.      @right_press = true
  220.    else
  221.      @right_press = false
  222.      @right_trigger = false
  223.      @right_repeat = false
  224.    end
  225. end
  226. def self.get_mouse_pos
  227.    point_var = [0, 0].pack('ll')
  228.    if $GetCursorPos.call(point_var) != 0
  229.      if $ScreenToClient.call($Window_HWND, point_var) != 0
  230.        x, y = point_var.unpack('ll')
  231.        if (x < 0) or (x > 10000) then x = 0 end
  232.        if (y < 0) or (y > 10000) then y = 0 end
  233.        if x > 640 then x = 640 end
  234.        if y > 480 then y = 480 end
  235.        return x, y
  236.      else
  237.        return 0, 0
  238.      end
  239.    else
  240.      return 0, 0
  241.    end
  242. end
  243. def self.press?(mouse_code)
  244.    if mouse_code == LEFT
  245.      if @click_lock
  246.        return false
  247.      else
  248.        return @left_press
  249.      end
  250.    elsif mouse_code == RIGHT
  251.      return @right_press
  252.    else
  253.      return false
  254.    end
  255. end
  256. def self.trigger?(mouse_code)
  257.    if mouse_code == LEFT
  258.      if @click_lock
  259.        return false
  260.      else
  261.        return @left_trigger
  262.      end
  263.    elsif mouse_code == RIGHT
  264.      return @right_trigger
  265.    else
  266.      return false
  267.    end
  268. end
  269. def self.repeat?(mouse_code)
  270.    if mouse_code == LEFT
  271.      if @click_lock
  272.        return false
  273.      else
  274.        return @left_repeat
  275.      end
  276.    elsif mouse_code == RIGHT
  277.      return @right_repeat
  278.    else
  279.      return false
  280.    end
  281. end
  282. def self.click_lock?
  283.    return @click_lock
  284. end
  285. def self.click_lock
  286.    @click_lock = true
  287. end
  288. def self.click_unlock
  289.    @click_lock = false
  290. end
  291. end
  292. module Input
  293. if @self_update == nil
  294.    @self_update = method('update')
  295.    @self_press = method('press?')
  296.    @self_trigger = method('trigger?')
  297.    @self_repeat = method('repeat?')
  298. end
  299. def self.update
  300.    @self_update.call
  301.    Mouse.update
  302. end
  303. def self.press?(key_code)
  304.    if @self_press.call(key_code)
  305.      return true
  306.    end
  307.    if key_code == C
  308.      return Mouse.press?(Mouse::LEFT)
  309.    elsif key_code == B
  310.      return Mouse.press?(Mouse::RIGHT)
  311.    else
  312.      return @self_press.call(key_code)
  313.    end
  314. end
  315. def self.trigger?(key_code)
  316.    if @self_trigger.call(key_code)
  317.      return true
  318.    end
  319.    if key_code == C
  320.      return Mouse.trigger?(Mouse::LEFT)
  321.    elsif key_code == B
  322.      return Mouse.trigger?(Mouse::RIGHT)
  323.    else
  324.      return @self_trigger.call(key_code)
  325.    end
  326. end
  327. def self.repeat?(key_code)
  328.    if @self_repeat.call(key_code)
  329.      return true
  330.    end
  331.    if key_code == C
  332.      return Mouse.repeat?(Mouse::LEFT)
  333.    elsif key_code == B
  334.      return Mouse.repeat?(Mouse::RIGHT)
  335.    else
  336.      return @self_repeat.call(key_code)
  337.    end
  338. end
  339. end
  340. class Window_Selectable
  341. if @self_alias == nil
  342.    alias self_update update
  343.    @self_alias = true
  344. end
  345. def update
  346.    self_update
  347.    if self.active and @item_max > 0
  348.      index_var = @index
  349.      tp_index = @index
  350.      mouse_x, mouse_y = Mouse.get_mouse_pos
  351.      mouse_not_in_rect = true
  352.      for i in 0...@item_max
  353.        @index = i
  354.        update_cursor_rect
  355.        top_x = self.cursor_rect.x + self.x + 16
  356.        top_y = self.cursor_rect.y + self.y + 16
  357.        bottom_x = top_x + self.cursor_rect.width
  358.        bottom_y = top_y + self.cursor_rect.height
  359.        if (mouse_x > top_x) and (mouse_y > top_y) and
  360.           (mouse_x < bottom_x) and (mouse_y < bottom_y)
  361.          mouse_not_in_rect = false
  362.          if tp_index != @index
  363.            tp_index = @index
  364.            $game_system.se_play($data_system.cursor_se)
  365.          end
  366.          break
  367.        end
  368.      end
  369.      if mouse_not_in_rect
  370.        @index = index_var
  371.        update_cursor_rect
  372.        Mouse.click_lock
  373.      else
  374.        Mouse.click_unlock               
  375.      end
  376.    end
  377. end
  378. end
  379. class Window_NameInput
  380. if @self_alias == nil
  381.    alias self_update update
  382.    @self_alias = true
  383. end
  384. def update
  385.    self_update
  386.    if self.active
  387.      index_var = @index
  388.      mouse_x, mouse_y = Mouse.get_mouse_pos
  389.      mouse_not_in_rect = true
  390.      for i in (0...CHARACTER_TABLE.size).to_a.push(180)
  391.        @index = i
  392.        update_cursor_rect
  393.        top_x = self.cursor_rect.x + self.x + 16
  394.        top_y = self.cursor_rect.y + self.y + 16
  395.        bottom_x = top_x + self.cursor_rect.width
  396.        bottom_y = top_y + self.cursor_rect.height
  397.        if (mouse_x > top_x) and (mouse_y > top_y) and
  398.           (mouse_x < bottom_x) and (mouse_y < bottom_y)
  399.          mouse_not_in_rect = false
  400.          break
  401.        end
  402.      end
  403.      if mouse_not_in_rect
  404.        @index = index_var
  405.        update_cursor_rect
  406.        Mouse.click_lock
  407.      else
  408.        Mouse.click_unlock
  409.      end
  410.    end
  411. end
  412. end
  413. class Window_InputNumber
  414. if @self_alias == nil
  415.    alias self_update update
  416.    @self_alias = true
  417. end
  418. def update
  419.    self_update
  420.    mouse_x, mouse_y = Mouse.get_mouse_pos
  421.    if self.active and @digits_max > 0
  422.      index_var = @index
  423.      mouse_not_in_rect = true
  424.      for i in 0...@digits_max
  425.        @index = i
  426.        update_cursor_rect
  427.        top_x = self.cursor_rect.x + self.x + 16
  428.        bottom_x = top_x + self.cursor_rect.width
  429.        if (mouse_x > top_x) and (mouse_x < bottom_x)
  430.          mouse_not_in_rect = false
  431.          break
  432.        end
  433.      end
  434.      if mouse_not_in_rect
  435.        @index = index_var
  436.        update_cursor_rect
  437.        Mouse.click_lock
  438.      else
  439.        Mouse.click_unlock
  440.      end
  441.    end
  442.    if @last_mouse_y == nil
  443.      @last_mouse_y = mouse_y
  444.    end
  445.    check_pos = (@last_mouse_y - mouse_y).abs
  446.    if check_pos > 10
  447.      $game_system.se_play($data_system.cursor_se)
  448.      place = 10 ** (@digits_max - 1 - @index)
  449.      n = @number / place % 10
  450.      @number -= n * place
  451.      n = (n + 1) % 10 if mouse_y < @last_mouse_y
  452.      n = (n + 9) % 10 if mouse_y > @last_mouse_y
  453.      @number += n * place
  454.      refresh
  455.      @last_mouse_y = mouse_y
  456.    end
  457. end
  458. end
  459. class Scene_File
  460. if @self_alias == nil
  461.    alias self_update update
  462.    @self_alias = true
  463. end
  464. def update
  465.    mouse_x, mouse_y = Mouse.get_mouse_pos
  466.    Mouse.click_lock
  467.    idx = 0
  468.    for i in @savefile_windows
  469.      top_x = i.x + 16
  470.      top_y = i.y + 16
  471.      bottom_x = top_x + i.width
  472.      bottom_y = top_y + i.height
  473.      if (mouse_x > top_x) and (mouse_y > top_y) and
  474.         (mouse_x < bottom_x) and (mouse_y < bottom_y)
  475.        i.selected = true
  476.        if @file_index != idx
  477.          @file_index = idx
  478.          $game_system.se_play($data_system.cursor_se)
  479.        end            
  480.        Mouse.click_unlock
  481.      else
  482.        i.selected = false
  483.      end
  484.      idx += 1
  485.    end
  486.    self_update
  487. end
  488. end
  489. class Arrow_Enemy
  490. if @self_alias == nil
  491.    alias self_update update
  492.    @self_alias = true
  493. end
  494. def update
  495.    mouse_x, mouse_y = Mouse.get_mouse_pos
  496.    idx = 0
  497.    for i in $game_troop.enemies do
  498.      if i.exist?
  499.        top_x = i.screen_x - self.ox
  500.        top_y = i.screen_y - self.oy
  501.        bottom_x = top_x + self.src_rect.width
  502.        bottom_y = top_y + self.src_rect.height
  503.        if (mouse_x > top_x - $敌人选框扩大) and (mouse_y > top_y - $敌人选框扩大) and
  504.           (mouse_x < bottom_x + $敌人选框扩大) and (mouse_y < bottom_y + $敌人选框扩大)
  505.          if @index != idx
  506.            $game_system.se_play($data_system.cursor_se)
  507.            @index = idx
  508.          end
  509.        end
  510.      end
  511.      idx += 1
  512.    end
  513.    self_update
  514. end
  515. end
  516. class Arrow_Actor
  517. if @self_alias == nil
  518.    alias self_update update
  519.    @self_alias = true
  520. end
  521. def update
  522.    mouse_x, mouse_y = Mouse.get_mouse_pos
  523.    idx = 0
  524.    for i in $game_party.actors do
  525.      if i.exist?
  526.        top_x = i.screen_x - self.ox
  527.        top_y = i.screen_y - self.oy
  528.        bottom_x = top_x + self.src_rect.width
  529.        bottom_y = top_y + self.src_rect.height
  530.        if (mouse_x > top_x - $角色选框扩大) and (mouse_y > top_y - $角色选框扩大) and
  531.           (mouse_x < bottom_x + $角色选框扩大) and (mouse_y < bottom_y + $角色选框扩大)
  532.          if @index != idx
  533.            $game_system.se_play($data_system.cursor_se)
  534.            @index = idx
  535.          end
  536.        end
  537.      end
  538.      idx += 1
  539.    end
  540.    self_update
  541. end
  542. end
  543. #==============================================================================
  544. # ■ Game_Player
  545. #------------------------------------------------------------------------------
  546. #  处理主角的类。事件启动的判定、以及地图的滚动等功能。
  547. # 本类的实例请参考 $game_player。
  548. #   鼠标控制角色的主程序
  549. #==============================================================================
  550. class Game_Player
  551. if @self_alias == nil
  552.    alias self_update update
  553.    @self_alias = true
  554. end
  555. #--------------------------------------------------------------------------
  556. # ● 得到鼠标的状态
  557. #--------------------------------------------------------------------------
  558. def get_mouse_sta
  559.    return @mouse_sta
  560. end
  561. #--------------------------------------------------------------------------
  562. # ● 完整鼠标系统
  563. #--------------------------------------------------------------------------
  564. def update
  565.    mouse_x, mouse_y = Mouse.get_mouse_pos
  566.    @mtp_x = mouse_x
  567.    @mtp_y = mouse_y
  568.    unless $game_system.map_interpreter.running? and @mouse_sta == 2 #鼠标状态不为跟随状态
  569.      #得到鼠标图标方向
  570.      $mouse_icon_id = $game_map.check_event_custom(mouse_x,mouse_y)  if not [11, 12, 13, 14, 16, 17, 18, 19].include?($mouse_icon_id)
  571.    else
  572.      #令鼠标图标为正常
  573.      $mouse_icon_id = 0 if @mouse_sta != 2
  574.    end
  575.    
  576.    #单击鼠标时进行判断寻路或跟随
  577.    if Mouse.trigger?(Mouse::LEFT) #当点击鼠标时
  578.      unless $game_system.map_interpreter.running? or
  579.             @move_route_forcing or $game_temp.message_window_showing #各种无效情况的排除
  580.        #初始化
  581.        @mouse_sta = 1
  582.        p_direction = 5
  583.        #检查鼠标处能否开启事件
  584.        event_start,p_direction = $game_map.check_event_custom_start(mouse_x, mouse_y)
  585.        #若在移动中再次点击鼠标左键(即双击左键),则改鼠标状态为跟随状态
  586.        @mouse_sta = 2 if @paths_id != nil and @paths_id != @paths.size
  587.        if @mouse_sta != 2
  588.          #鼠标状态不为跟随状态则取数据并初始化路径
  589.          trg_x = (mouse_x + $game_map.display_x / 4) / 32
  590.          trg_y = (mouse_y + $game_map.display_y / 4) / 32
  591.          @paths = []
  592.          @paths_id = 0
  593.          if event_start == 0 #若不能开启事件
  594.            if trg_x != $game_player.x or trg_y != $game_player.y #若目标不为自身则开始寻路
  595.              find_path = Find_Path.new
  596.              @paths = find_path.find_player_short_path(trg_x, trg_y, @mtp_x, @mtp_y)
  597.            end
  598.          else #若能开启事件则改变角色朝向
  599.            @direction = p_direction
  600.          end
  601.        end
  602.      end
  603.    end
  604.    #开始移动
  605.    if @mouse_sta != nil and @mouse_sta == 1 #若鼠标状态为寻路状态
  606.      unless moving? or $game_system.map_interpreter.running? or
  607.             @move_route_forcing or $game_temp.message_window_showing #排除无效情况
  608.        if @paths_id != nil and @paths != nil and @paths_id <= @paths.size #若没有完成路径
  609.          case @paths[@paths_id] #判断路径
  610.          when 6
  611.            @last_move_x = true
  612.            move_right
  613.            @paths_id += 1
  614.            @direction = 6
  615.          when 4
  616.            @last_move_x = true
  617.            move_left
  618.            @paths_id += 1
  619.            @direction = 4
  620.          when 2
  621.            @last_move_x = false
  622.            move_down
  623.            @direction = 2
  624.            @paths_id += 1
  625.          when 8
  626.            @last_move_x = false
  627.            move_up
  628.            @direction = 8
  629.            @paths_id += 1
  630.          #斜四方向
  631.          when 1
  632.            @last_move_x = false
  633.            move_lower_left
  634.            @direction = 1
  635.            @paths_id += 1
  636.          when 3
  637.            @last_move_x = false
  638.            move_lower_right
  639.            @direction = 3
  640.            @paths_id += 1
  641.          when 7
  642.            @last_move_x = false
  643.            move_upper_left
  644.            @direction = 7
  645.            @paths_id += 1
  646.          when 9
  647.            @last_move_x = false
  648.            move_upper_right
  649.            @direction = 9
  650.            @paths_id += 1
  651.          end
  652.        end
  653.      end
  654.    elsif @paths != nil and @mouse_sta == 2 #当鼠标状态为跟随,且在移动中
  655.      
  656. if $game_switches[123]
  657.      if Mouse.press?(Mouse::LEFT)
  658.        for event in $game_map.events.values
  659.          if event.screen_x/32 == mouse_x/32 and event.screen_y/32-1 == mouse_y/32
  660.            event.start
  661.          end
  662.        end
  663.      end
  664.      self_update
  665.      return
  666.    end
  667.      if Mouse.press?(Mouse::LEFT) #持续按住鼠标
  668.        unless moving? or $game_system.map_interpreter.running? or
  669.               @move_route_forcing or $game_temp.message_window_showing #排除无效情况
  670.          #跟随方向判断并跟随
  671.          rate =  $game_map.show_rate(self)
  672.          width = (RPG::Cache.character(self.character_name,self.character_hue).width / $c3_每一步的帧数) * rate
  673.          height = (RPG::Cache.character(self.character_name,self.character_hue).height / 8) * rate
  674.          self_ox = (self.screen_x - width / 2 + self.screen_x + width / 2) / 2
  675.          self_oy = (self.screen_y - height + self.screen_y) / 2
  676.          #self_ox = self.screen_x
  677.          #self_oy = self.screen_y
  678.          if (@mtp_x - self_ox)*(@mtp_x - self_ox) + (@mtp_y - self_oy)*(@mtp_y - self_oy) >= 961
  679.            if @mtp_x > self_ox
  680.              if self_oy - @mtp_y < 0.4 * (@mtp_x - self_ox) and
  681.                 @mtp_y - self_oy < 0.4 * (@mtp_x - self_ox)
  682.                move_right
  683.                $mouse_icon_id = 16
  684.                @direction = 6
  685.              end
  686.              if @mtp_y - self_oy > - 0.4 * ( self_ox - @mtp_x ) and
  687.                 @mtp_y - self_oy < - 2.4 * ( self_ox - @mtp_x )
  688.                move_lower_right
  689.                $mouse_icon_id = 13
  690.                @direction = 3
  691.              end
  692.              if @mtp_y - self_oy < 0.4 * ( self_ox - @mtp_x ) and
  693.                 @mtp_y - self_oy > 2.4 * ( self_ox - @mtp_x )
  694.                move_upper_right
  695.                $mouse_icon_id = 19
  696.                @direction = 9
  697.              end
  698.              if @mtp_y - self_oy > 2.4 * ( @mtp_x - self_ox )
  699.                move_down
  700.                $mouse_icon_id = 12
  701.                @direction = 2
  702.              end
  703.              if @mtp_y - self_oy < - 2.4 * ( @mtp_x - self_ox )
  704.                move_up
  705.                $mouse_icon_id = 18
  706.                @direction = 8
  707.              end
  708.            end
  709.            if @mtp_x < self_ox
  710.              if @mtp_y - self_oy > - 0.4 * ( self_ox - @mtp_x ) and
  711.                 @mtp_y - self_oy < 0.4 * ( self_ox - @mtp_x )
  712.                move_left
  713.                $mouse_icon_id = 14
  714.                @direction = 4
  715.              end
  716.              if @mtp_y - self_oy > 0.4 * ( self_ox - @mtp_x ) and
  717.                 @mtp_y - self_oy < 2.4 * ( self_ox - @mtp_x )
  718.                move_lower_left
  719.                $mouse_icon_id = 11
  720.                @direction = 1
  721.              end
  722.              if @mtp_y - self_oy < - 0.4 * ( self_ox - @mtp_x ) and
  723.                 @mtp_y - self_oy > - 2.4 * ( self_ox - @mtp_x )
  724.                move_upper_left
  725.                $mouse_icon_id = 17
  726.                @direction = 7
  727.              end
  728.              if @mtp_y - self_oy > 2.4 * ( self_ox - @mtp_x )
  729.                move_down
  730.                $mouse_icon_id = 12
  731.                @direction = 2
  732.              end
  733.              if @mtp_y - self_oy < - 2.4 * ( self_ox - @mtp_x )
  734.                move_up
  735.                $mouse_icon_id = 18
  736.                @direction = 8
  737.              end
  738.            end
  739.          end
  740.            #...................................................................
  741.            if @mtp_x > self_ox
  742.              if @mtp_y - self_oy > - 0.4 * ( @mtp_x - self_ox ) and
  743.                 @mtp_y - self_oy < 0.4 * ( @mtp_x - self_ox )
  744.                $mouse_icon_id = 16
  745.                @direction = 6
  746.              end
  747.              if @mtp_y - self_oy > 0.4 * ( @mtp_x - self_ox ) and
  748.                @mtp_y - self_oy < 2.4 * ( @mtp_x - self_ox )
  749.                $mouse_icon_id = 13
  750.                @direction = 3
  751.              end
  752.              if @mtp_y - self_oy < - 0.4 * ( @mtp_x - self_ox ) and
  753.                @mtp_y - self_oy > - 2.4 * ( @mtp_x - self_ox )
  754.                $mouse_icon_id = 19
  755.                @direction = 9
  756.              end
  757.              if @mtp_y - self_oy > 2.4 * ( @mtp_x - self_ox )
  758.                $mouse_icon_id = 12
  759.                @direction = 2
  760.              end
  761.              if @mtp_y - self_oy < - 2.4 * ( @mtp_x - self_ox )
  762.                $mouse_icon_id = 18
  763.                @direction = 8
  764.              end
  765.            end
  766.            if @mtp_x < self_ox
  767.              if @mtp_y - self_oy > - 0.4 * ( self_ox - @mtp_x ) and
  768.                 @mtp_y - self_oy < 0.4 * ( self_ox - @mtp_x )
  769.                $mouse_icon_id = 14
  770.                @direction = 4
  771.              end
  772.              if @mtp_y - self_oy > 0.4 * ( self_ox - @mtp_x ) and
  773.                 @mtp_y - self_oy < 2.4 * ( self_ox - @mtp_x )
  774.                $mouse_icon_id = 11
  775.                @direction = 1
  776.              end
  777.              if @mtp_y - self_oy < - 0.4 * ( self_ox - @mtp_x ) and
  778.                 @mtp_y - self_oy > - 2.4 * ( self_ox - @mtp_x )
  779.                $mouse_icon_id = 17
  780.                @direction = 7
  781.              end
  782.              if @mtp_y - self_oy > 2.4 * ( self_ox - @mtp_x )
  783.                $mouse_icon_id = 12
  784.                @direction = 2
  785.              end
  786.              if @mtp_y - self_oy < - 2.4 * ( self_ox - @mtp_x )
  787.                $mouse_icon_id = 18
  788.                @direction = 8
  789.              end
  790.            end
  791.            #...................................................................
  792.        end
  793.      else #没状态的情况
  794.        $mouse_icon_id = 0
  795.        @mouse_sta = 0
  796.        @paths_id = @paths.size #终止寻路移动
  797.      end
  798.    end
  799.    self_update
  800. end
  801. end
  802. Mouse.init
  803. END { Mouse.exit }
  804. 您正在看的文章来自幻想森林论坛 [url]http://www.rpgchina.net[/url],原文地址:[url]http://www.rpgchina.net/read.php?tid=34682[/url]
复制代码
回复 支持 反对

使用道具 举报

550

主题

9116

帖子

214748万

积分

超级版主

如同神一般的存在,腿神!拖后腿的神~~

Rank: 8Rank: 8

积分
2147483647
发表于 2009-2-28 16:05:20 | 显示全部楼层

Re:rmxp使了鼠标整和脚本,在任何窗口鼠标都能控制光标,就在

别人已经写好的是已经把 默认的窗口集合进去了

你自己做的窗口又没有写进去。。。所以要自己写
我就是你们的神,庶民们,追随我吧!跟着我一起拖后腿!
回复 支持 反对

使用道具 举报

550

主题

9116

帖子

214748万

积分

超级版主

如同神一般的存在,腿神!拖后腿的神~~

Rank: 8Rank: 8

积分
2147483647
发表于 2009-2-28 16:06:20 | 显示全部楼层

Re:rmxp使了鼠标整和脚本,在任何窗口鼠标都能控制光标,就在

class Scene_File
if @self_alias == nil
   alias self_update update
   @self_alias = true
end
def update
   mouse_x, mouse_y = Mouse.get_mouse_pos
   Mouse.click_lock
   idx = 0
   for i in @savefile_windows
     top_x = i.x + 16
     top_y = i.y + 16
     bottom_x = top_x + i.width
     bottom_y = top_y + i.height
     if (mouse_x > top_x) and (mouse_y > top_y) and
        (mouse_x < bottom_x) and (mouse_y < bottom_y)
       i.selected = true
       if @file_index != idx
         @file_index = idx
         $game_system.se_play($data_system.cursor_se)
       end            
       Mouse.click_unlock
     else
       i.selected = false
     end
     idx += 1
   end
   self_update
end
end
class Arrow_Enemy
if @self_alias == nil
   alias self_update update
   @self_alias = true
end
def update
   mouse_x, mouse_y = Mouse.get_mouse_pos
   idx = 0
   for i in $game_troop.enemies do
     if i.exist?
       top_x = i.screen_x - self.ox
       top_y = i.screen_y - self.oy
       bottom_x = top_x + self.src_rect.width
       bottom_y = top_y + self.src_rect.height
       if (mouse_x > top_x - $敌人选框扩大) and (mouse_y > top_y - $敌人选框扩大) and
          (mouse_x < bottom_x + $敌人选框扩大) and (mouse_y < bottom_y + $敌人选框扩大)
         if @index != idx
           $game_system.se_play($data_system.cursor_se)
           @index = idx
         end
       end
     end
     idx += 1
   end
   self_update
end
end
class Arrow_Actor
if @self_alias == nil
   alias self_update update
   @self_alias = true
end
def update
   mouse_x, mouse_y = Mouse.get_mouse_pos
   idx = 0
   for i in $game_party.actors do
     if i.exist?
       top_x = i.screen_x - self.ox
       top_y = i.screen_y - self.oy
       bottom_x = top_x + self.src_rect.width
       bottom_y = top_y + self.src_rect.height
       if (mouse_x > top_x - $角色选框扩大) and (mouse_y > top_y - $角色选框扩大) and
          (mouse_x < bottom_x + $角色选框扩大) and (mouse_y < bottom_y + $角色选框扩大)
         if @index != idx
           $game_system.se_play($data_system.cursor_se)
           @index = idx
         end
       end
     end
     idx += 1
   end
   self_update
end
end
您正在看的文章来自幻想森林论坛 http://www.rpgchina.net,原文地址:http://www.rpgchina.net/read.php?tid=34710


看没看到,别人把默认的窗口都写好了
我就是你们的神,庶民们,追随我吧!跟着我一起拖后腿!
回复 支持 反对

使用道具 举报

9

主题

26

帖子

237

积分

③业余

积分
237
 楼主| 发表于 2009-2-28 16:46:19 | 显示全部楼层

Re:rmxp使了鼠标整和脚本,在任何窗口鼠标都能控制光标,就在

喔 明白了。  谢谢老大
回复 支持 反对

使用道具 举报

9

主题

26

帖子

237

积分

③业余

积分
237
 楼主| 发表于 2009-2-28 17:01:08 | 显示全部楼层

Re:rmxp使了鼠标整和脚本,在任何窗口鼠标都能控制光标,就在

但是还是不知道 我建立了一个窗口 怎么 写 进 鼠标脚本。。
回复 支持 反对

使用道具 举报

550

主题

9116

帖子

214748万

积分

超级版主

如同神一般的存在,腿神!拖后腿的神~~

Rank: 8Rank: 8

积分
2147483647
发表于 2009-2-28 17:09:56 | 显示全部楼层

Re:rmxp使了鼠标整和脚本,在任何窗口鼠标都能控制光标,就在

仿照那个吧。。。。就是获取鼠标的x,y

来判断位置是不是指在选项上
我就是你们的神,庶民们,追随我吧!跟着我一起拖后腿!
回复 支持 反对

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-5-23 23:07 , Processed in 0.026358 second(s), 20 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

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