Project1

标题: 如何添加鼠标特效?在线等! [打印本页]

作者: a107480098    时间: 2015-6-6 17:22
标题: 如何添加鼠标特效?在线等!
如题:如何添加鼠标特效?我想让鼠标点击左键时,在角色行走和寻路状态下添加一个动画效果或者添加一组连续的图片作为动画特效,
鼠标点击图片按钮除外,有办法实现吗?附上我自己的鼠标脚本。最好来个范例工程。谢谢!


RUBY 代码复制
  1. # 八向行走鼠标脚本系列处理★★★★★★★★★★★★★★★★★★★★★★★★★
  2. #=================以下两个用来调整战斗时的手感问题,可以自己试试。
  3. $敌人选框扩大 = 20
  4. $角色选框扩大 = 30
  5. #==============================================================================
  6. # ● API调用
  7. #==============================================================================
  8. $ShowCursor = Win32API.new("user32", "ShowCursor", 'i', 'l')
  9. $GetCursorPos = Win32API.new("user32", "GetCursorPos", 'p', 'i')
  10. $ScreenToClient = Win32API.new("user32", "ScreenToClient", 'ip', 'i')
  11. $GetActiveWindow = Win32API.new("user32", "GetActiveWindow", nil, 'l')
  12. $Window_HWND = $GetActiveWindow.call
  13. $GetKeyState = Win32API.new("user32", "GetKeyState", 'i', 'i')
  14. module Mouse  
  15. LEFT = 0x01
  16. RIGHT = 0x02
  17. def self.init(sprite = nil)
  18.    $ShowCursor.call(0)
  19.  
  20.  
  21.    @cun = 8
  22.     @show_cursor = false
  23.     @mouse_sprite = Sprite.new
  24.     @mouse_sprite.z = 99999
  25.     @mouse_sprite.bitmap = Bitmap.new("Graphics/Mouse/Normal_p")
  26.     @mouse_sprite.src_rect.set(0, 0, 40, 39)
  27.     @mouse_sprite.src_rect.x = (@cun / 8) % 8 * 40
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.    @left_press = false
  41.    @right_press = false
  42.    @left_trigger = false
  43.    @right_trigger = false
  44.    @left_repeat = false
  45.    @right_repeat = false
  46.    @click_lock = false
  47.    update
  48. end
  49. def self.exit
  50.    @mouse_sprite.bitmap.dispose
  51.    @mouse_sprite.dispose
  52.    @show_cursor = true
  53.    $ShowCursor.call(1)
  54. end
  55. def self.mouse_debug
  56.    return @mouse_debug.bitmap
  57. end
  58. def self.update
  59.    left_down = $GetKeyState.call(0x01)
  60.    right_down = $GetKeyState.call(0x02)
  61.     if @cun < 9999
  62.       #if Graphics.frame_count % 2 == 0
  63.         @cun += 1
  64.       #end
  65.     elsif @cun >= 9999 and @cun > 0
  66.       #if Graphics.frame_count % 2 == 0
  67.         @cun -= 1
  68.       #end
  69.     end
  70.     @mouse_sprite.src_rect.set(0, 0, 40, 39)
  71.     @mouse_sprite.src_rect.x = (@cun / 8) % 8 * 40
  72.     @click_lock = false
  73.  
  74.  
  75.      mouse_x, mouse_y = self.get_mouse_pos
  76.     if @mouse_sprite != nil
  77.       @mouse_sprite.x = mouse_x
  78.       @mouse_sprite.y = mouse_y
  79.     end
  80.     if left_down[7] == 1
  81.       @left_repeat = (not @left_repeat)
  82.       @left_trigger = (not @left_press)
  83.       @left_press = true
  84.     else
  85.       @left_press = false
  86.       @left_trigger = false
  87.       @left_repeat = false
  88.     end
  89.     if right_down[7] == 1
  90.       @right_repeat = (not @right_repeat)
  91.       @right_trigger = (not @right_press)
  92.       @right_press = true
  93.     else
  94.       @right_press = false
  95.       @right_trigger = false
  96.       @right_repeat = false
  97.     end
  98.   end
  99.   def self.get_mouse_pos
  100.     point_var = [0, 0].pack('ll')
  101.     if $GetCursorPos.call(point_var) != 0
  102.       if $ScreenToClient.call($Window_HWND, point_var) != 0
  103.         x, y = point_var.unpack('ll')
  104.         if (x < 0) or (x > 10000) then x = 0 end
  105.         if (y < 0) or (y > 10000) then y = 0 end
  106.         if x > 640 then x = 640 end
  107.         if y > 480 then y = 480 end
  108.         return x, y
  109.       else
  110.         return 0, 0
  111.       end
  112.     else
  113.       return 0, 0
  114.     end
  115.   end
  116.   def self.press?(mouse_code)
  117.     if mouse_code == LEFT
  118.       if @click_lock
  119.         return false
  120.       else
  121.         return @left_press
  122.       end
  123.     elsif mouse_code == RIGHT
  124.       return @right_press
  125.     else
  126.       return false
  127.     end
  128.   end
  129.   def self.trigger?(mouse_code)
  130.     if mouse_code == LEFT
  131.       if @click_lock
  132.         return false
  133.       else
  134.         return @left_trigger
  135.       end
  136.     elsif mouse_code == RIGHT
  137.       return @right_trigger
  138.     else
  139.       return false
  140.     end
  141.   end
  142.   def self.repeat?(mouse_code)
  143.     if mouse_code == LEFT
  144.       if @click_lock
  145.         return false
  146.       else
  147.         return @left_repeat
  148.       end
  149.     elsif mouse_code == RIGHT
  150.       return @right_repeat
  151.     else
  152.       return false
  153.     end
  154.   end
  155.   def self.click_lock?
  156.     return @click_lock
  157.   end
  158.   def self.click_lock
  159.     @click_lock = true
  160.   end
  161.   def self.click_unlock
  162.     @click_lock = false
  163.   end
  164. end
  165.  
  166.  
  167. module Input
  168. if @self_update == nil
  169.    @self_update = method('update')
  170.    @self_press = method('press?')
  171.    @self_trigger = method('trigger?')
  172.    @self_repeat = method('repeat?')
  173. end
  174. def self.update
  175.    @self_update.call
  176.    Mouse.update
  177. end
  178. def self.press?(key_code)
  179.    if @self_press.call(key_code)
  180.      return true
  181.    end
  182.    if key_code == C
  183.      return Mouse.press?(Mouse::LEFT)
  184.    elsif key_code == B
  185.      return Mouse.press?(Mouse::RIGHT)
  186.    else
  187.      return @self_press.call(key_code)
  188.    end
  189. end
  190. def self.trigger?(key_code)
  191.    if @self_trigger.call(key_code)
  192.      return true
  193.    end
  194.    if key_code == C
  195.      return Mouse.trigger?(Mouse::LEFT)
  196.    elsif key_code == B
  197.      return Mouse.trigger?(Mouse::RIGHT)
  198.    else
  199.      return @self_trigger.call(key_code)
  200.    end
  201. end
  202. def self.repeat?(key_code)
  203.    if @self_repeat.call(key_code)
  204.      return true
  205.    end
  206.    if key_code == C
  207.      return Mouse.repeat?(Mouse::LEFT)
  208.    elsif key_code == B
  209.      return Mouse.repeat?(Mouse::RIGHT)
  210.    else
  211.      return @self_repeat.call(key_code)
  212.    end
  213. end
  214. end
  215. class Window_Selectable
  216.   if @self_alias == nil
  217.     alias self_update update
  218.     @self_alias = true
  219.   end
  220.   def update
  221.     self_update
  222.     if self.active and @item_max > 0
  223.       index_var = @index
  224.       tp_index = @index
  225.       mouse_x, mouse_y = Mouse.get_mouse_pos
  226.       mouse_not_in_rect = true
  227.       for i in 0...@item_max
  228.         @index = i
  229.         update_cursor_rect
  230.         top_x = self.cursor_rect.x + self.x + 16
  231.         top_y = self.cursor_rect.y + self.y + 16
  232.         bottom_x = top_x + self.cursor_rect.width
  233.         bottom_y = top_y + self.cursor_rect.height
  234.         if (mouse_x > top_x) and (mouse_y > top_y) and
  235.            (mouse_x < bottom_x) and (mouse_y < bottom_y)
  236.           mouse_not_in_rect = false
  237.           if tp_index != @index
  238.             tp_index = @index
  239.             $game_system.se_play($data_system.cursor_se)
  240.           end
  241.           break
  242.         end
  243.       end
  244.       if mouse_not_in_rect
  245.           # 当前行被显示开头行前面的情况下
  246.           if self.top_row < row_max-page_row_max and Mouse.press?(Mouse::LEFT) and mouse_y>self.y+self.height/2
  247.             self.top_row +=1
  248.           end
  249.           # 当前行被显示末尾行之后的情况下
  250.           if self.top_row > 0 and Mouse.press?(Mouse::LEFT) and mouse_y<=self.y+self.height/2#self.top_row + (self.page_row_max - 1)
  251.             # 从当前行向末尾滚动
  252.             self.top_row -=1
  253.           end
  254.         @index = index_var
  255.         if self.is_a?(Window_Target)
  256.           @index=-3
  257.         end
  258.         update_cursor_rect
  259.         Mouse.click_lock
  260.       else
  261.         Mouse.click_unlock               
  262.       end
  263.     end
  264.   end
  265.   def update_cursor_rect
  266.     # 光标位置不满 0 的情况下
  267.     if @index < 0
  268.       self.cursor_rect.empty
  269.       return
  270.     end
  271.     # 获取当前的行
  272.     row = @index / @column_max
  273.     # 当前行被显示开头行前面的情况下
  274.     if row < self.top_row
  275.       # 从当前行向开头行滚动
  276.       self.cursor_rect.empty
  277.       return
  278.     end
  279.     # 当前行被显示末尾行之后的情况下
  280.     if row > self.top_row + (self.page_row_max - 1)
  281.       # 从当前行向末尾滚动
  282.       self.cursor_rect.empty
  283.       return
  284.     end
  285.     # 计算光标的宽
  286.     cursor_width = self.width / @column_max - 32
  287.     # 计算光标坐标
  288.     x = @index % @column_max * (cursor_width + 32)
  289.     y = @index / @column_max * 32 - self.oy
  290.     # 更新光标矩形
  291.     self.cursor_rect.set(x, y, cursor_width, 32)
  292.   end
  293. end
  294.  
  295.  
  296.  
  297.  
  298.  
  299.  
  300.  
  301.  
  302.  
  303.  
  304.  
  305.  
  306.  
  307.  
  308. ##################################################################class Window_Selectable
  309.   class Window_Selectableshen
  310. if @self_alias == nil
  311.     alias self_update update
  312.     @self_alias = true
  313.   end
  314.   def update
  315.     self_update
  316.     if self.active and @item_max > 0
  317.       index_var = @index
  318.       tp_index = @index
  319.       mouse_x, mouse_y = Mouse.get_mouse_pos
  320.       mouse_not_in_rect = true
  321.       for i in 0...@item_max
  322.         @index = i
  323.         update_cursor_rect
  324.         top_x = self.cursor_rect.x + self.x + 16
  325.         top_y = self.cursor_rect.y + self.y + 16
  326.         bottom_x = top_x + self.cursor_rect.width
  327.         bottom_y = top_y + self.cursor_rect.height
  328.         if (mouse_x > top_x) and (mouse_y > top_y) and
  329.            (mouse_x < bottom_x) and (mouse_y < bottom_y)
  330.           mouse_not_in_rect = false
  331.           if tp_index != @index
  332.             tp_index = @index
  333.             $game_system.se_play($data_system.cursor_se)
  334.           end
  335.           break
  336.         end
  337.       end
  338.       if mouse_not_in_rect
  339.           # 当前行被显示开头行前面的情况下
  340.           if self.top_row < row_max-page_row_max and Mouse.press?(Mouse::LEFT) and mouse_y>self.y+self.height/2
  341.             self.top_row +=1
  342.           end
  343.           # 当前行被显示末尾行之后的情况下
  344.           if self.top_row > 0 and Mouse.press?(Mouse::LEFT) and mouse_y<=self.y+self.height/2#self.top_row + (self.page_row_max - 1)
  345.             # 从当前行向末尾滚动
  346.             self.top_row -=1
  347.           end
  348.         @index = index_var
  349.         if self.is_a?(Window_Target)
  350.           @index=-3
  351.         end
  352.         update_cursor_rect
  353.         Mouse.click_lock
  354.       else
  355.         Mouse.click_unlock               
  356.       end
  357.     end
  358.   end
  359.   def update_cursor_rect
  360.     # 光标位置不满 0 的情况下
  361.     if @index < 0
  362.       self.cursor_rect.empty
  363.       return
  364.     end
  365.     # 获取当前的行
  366.     row = @index / @column_max
  367.     # 当前行被显示开头行前面的情况下
  368.     if row < self.top_row
  369.       # 从当前行向开头行滚动
  370.       self.cursor_rect.empty
  371.       return
  372.     end
  373.     # 当前行被显示末尾行之后的情况下
  374.     if row > self.top_row + (self.page_row_max - 1)
  375.       # 从当前行向末尾滚动
  376.       self.cursor_rect.empty
  377.       return
  378.     end
  379.     # 计算光标的宽
  380.     cursor_width = self.width / @column_max - 24
  381.     # 计算光标坐标
  382.     x = @index % @column_max * (cursor_width + 24)
  383.     y = @index / @column_max * 24 - self.oy
  384.     # 更新光标矩形
  385.     self.cursor_rect.set(x, y, cursor_width, 24)
  386.   end
  387. end
  388. ###############################################################################
  389.  
  390.  
  391.  
  392.  
  393.  
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400.  
  401.  
  402.  
  403.  
  404.  
  405.  
  406.  
  407.  
  408.  
  409.  
  410.  
  411.  
  412.  
  413.  
  414.  
  415.  
  416.  
  417.  
  418.  
  419.  
  420.  
  421.  
  422.  
  423.  
  424.  
  425.  
  426.  
  427.  
  428.  
  429.  
  430.  
  431.  
  432.  
  433.  
  434.  
  435.  
  436.  
  437.  
  438.  
  439.  
  440.  
  441. class Window_NameInput
  442. if @self_alias == nil
  443.    alias self_update update
  444.    @self_alias = true
  445. end
  446. def update
  447.    self_update
  448.    if self.active
  449.      index_var = @index
  450.      mouse_x, mouse_y = Mouse.get_mouse_pos
  451.      mouse_not_in_rect = true
  452.      for i in (0...CHARACTER_TABLE.size).to_a.push(180)
  453.        @index = i
  454.        update_cursor_rect
  455.        top_x = self.cursor_rect.x + self.x + 16
  456.        top_y = self.cursor_rect.y + self.y + 16
  457.        bottom_x = top_x + self.cursor_rect.width
  458.        bottom_y = top_y + self.cursor_rect.height
  459.        if (mouse_x > top_x) and (mouse_y > top_y) and
  460.           (mouse_x < bottom_x) and (mouse_y < bottom_y)
  461.          mouse_not_in_rect = false
  462.          break
  463.        end
  464.      end
  465.      if mouse_not_in_rect
  466.        @index = index_var
  467.        update_cursor_rect
  468.        Mouse.click_lock
  469.      else
  470.        Mouse.click_unlock
  471.      end
  472.    end
  473. end
  474. end
  475. class Window_InputNumber
  476. if @self_alias == nil
  477.    alias self_update update
  478.    @self_alias = true
  479. end
  480. def update
  481.    self_update
  482.    mouse_x, mouse_y = Mouse.get_mouse_pos
  483.    if self.active and @digits_max > 0
  484.      index_var = @index
  485.      mouse_not_in_rect = true
  486.      for i in 0...@digits_max
  487.        @index = i
  488.        update_cursor_rect
  489.        top_x = self.cursor_rect.x + self.x + 16
  490.        bottom_x = top_x + self.cursor_rect.width
  491.        if (mouse_x > top_x) and (mouse_x < bottom_x)
  492.          mouse_not_in_rect = false
  493.          break
  494.        end
  495.      end
  496.      if mouse_not_in_rect
  497.        @index = index_var
  498.        update_cursor_rect
  499.        Mouse.click_lock
  500.      else
  501.        Mouse.click_unlock
  502.      end
  503.    end
  504.    if @last_mouse_y == nil
  505.      @last_mouse_y = mouse_y
  506.    end
  507.    check_pos = (@last_mouse_y - mouse_y).abs
  508.    if check_pos > 10
  509.      $game_system.se_play($data_system.cursor_se)
  510.      place = 10 ** (@digits_max - 1 - @index)
  511.      n = @number / place % 10
  512.      @number -= n * place
  513.      n = (n + 1) % 10 if mouse_y < @last_mouse_y
  514.      n = (n + 9) % 10 if mouse_y > @last_mouse_y
  515.      @number += n * place
  516.      refresh
  517.      @last_mouse_y = mouse_y
  518.    end
  519. end
  520. end
  521. class Scene_File
  522. if @self_alias == nil
  523.    alias self_update update
  524.    @self_alias = true
  525. end
  526. def update
  527.    mouse_x, mouse_y = Mouse.get_mouse_pos
  528.    Mouse.click_lock
  529.    idx = 0
  530.    for i in @savefile_windows
  531.      top_x = i.x + 16
  532.      top_y = i.y + 16
  533.      bottom_x = top_x + i.width
  534.      bottom_y = top_y + i.height
  535.      if (mouse_x > top_x) and (mouse_y > top_y) and
  536.         (mouse_x < bottom_x) and (mouse_y < bottom_y)
  537.        i.selected = true
  538.        if @file_index != idx
  539.          @file_index = idx
  540.          $game_system.se_play($data_system.cursor_se)
  541.        end            
  542.        Mouse.click_unlock
  543.      else
  544.        i.selected = false
  545.      end
  546.      idx += 1
  547.    end
  548.    self_update
  549. end
  550. end
  551. class Arrow_Enemy
  552. if @self_alias == nil
  553.    alias self_update update
  554.    @self_alias = true
  555. end
  556. def update
  557.    mouse_x, mouse_y = Mouse.get_mouse_pos
  558.    idx = 0
  559.    for i in $game_troop.enemies do
  560.      if i.exist?
  561.        top_x = i.screen_x - self.ox - 420
  562.        top_y = i.screen_y - self.oy - 50
  563.        bottom_x = top_x + self.src_rect.width
  564.        bottom_y = top_y + self.src_rect.height
  565.        if (mouse_x > top_x - $敌人选框扩大) and (mouse_y > top_y - $敌人选框扩大) and
  566.           (mouse_x < bottom_x + $敌人选框扩大) and (mouse_y < bottom_y + $敌人选框扩大)
  567.          if @index != idx
  568.            $game_system.se_play($data_system.cursor_se)
  569.            @index = idx
  570.          end
  571.        end
  572.      end
  573.      idx += 1
  574.    end
  575.    self_update
  576. end
  577. end
  578. class Arrow_Actor
  579. if @self_alias == nil
  580.    alias self_update update
  581.    @self_alias = true
  582. end
  583. def update
  584.    mouse_x, mouse_y = Mouse.get_mouse_pos
  585.    idx = 0
  586.    for i in $game_party.actors do
  587.      #if i.exist? #不注释掉,角色死亡后就不能用鼠标了!
  588.        top_x = i.screen_x - self.ox - 420
  589.        top_y = i.screen_y - self.oy - 50
  590.        bottom_x = top_x + self.src_rect.width
  591.        bottom_y = top_y + self.src_rect.height
  592.        if (mouse_x > top_x - $角色选框扩大) and (mouse_y > top_y - $角色选框扩大) and
  593.           (mouse_x < bottom_x + $角色选框扩大) and (mouse_y < bottom_y + $角色选框扩大)
  594.          if @index != idx
  595.            $game_system.se_play($data_system.cursor_se)
  596.            @index = idx
  597.          end
  598.        end
  599.      #end #不注释掉,角色死亡后就不能用鼠标了!
  600.      idx += 1
  601.    end
  602.    self_update
  603. end
  604. end
  605.  
  606. class Game_Player
  607. if @self_alias == nil
  608.    alias self_update update
  609.    @self_alias = true
  610. end
  611.  
  612. def get_mouse_sta
  613.    return @mouse_sta
  614. end
  615.  
  616. def update
  617.    mouse_x, mouse_y = Mouse.get_mouse_pos
  618.    @mtp_x = mouse_x
  619.    @mtp_y = mouse_y
  620.  
  621.     # 宝宝按扭
  622.  
  623.  
  624.            if @mtp_x >= 422 and @mtp_x <= 452 and @mtp_y >= 450 and @mtp_y <= 477
  625.      $game_screen.pictures[1].show("宠物1", 0, 418, 430, 100.0, 100.0, 255, 0)
  626.  
  627.      #$game_screen.pictures[30].show("宝宝", 0, 428, 452, 100.0, 100.0, 255, 0)
  628.      if Input.trigger?(Input::C)
  629.        $game_system.se_play($data_system.decision_se); $game_screen.pictures[1].erase
  630.       $game_screen.pictures[30].erase
  631.         Audio.se_play("Audio/SE/"+"退出",100,100)
  632.     $scene =  Scene_Baby.new
  633.         # $scene = Scene_Menu.new
  634.  
  635.         #$game_temp.common_event_id = 21
  636.       end
  637.     else
  638.       $game_screen.pictures[1].erase
  639.             $game_screen.pictures[30].erase
  640.       end
  641.  
  642.  
  643.  
  644.  
  645.  
  646.  
  647.  
  648.  
  649.  
  650.     if @mtp_x >= 0 and @mtp_x <= 30 and @mtp_y >= 450 and @mtp_y <= 477
  651.      #$game_screen.pictures[4].show("时间", 0, 402, 452, 100.0, 100.0, 255, 0)
  652.      if Input.trigger?(Input::C)
  653.  
  654.        $game_system.se_play($data_system.decision_se); $game_screen.pictures[50].erase
  655.        Audio.se_play("Audio/SE/"+"退出",100,100)
  656.        $game_temp.common_event_id = 60
  657.       end
  658.    else
  659.      # $game_screen.pictures[4].erase
  660.  
  661.    end
  662.  
  663.  
  664.  
  665.  
  666.  
  667.  
  668.  
  669.  
  670.  
  671.  
  672.  
  673.  
  674.  
  675.  
  676.  
  677.  
  678.  
  679.  
  680.     if @mtp_x >= 392 and @mtp_x <= 422 and @mtp_y >= 450 and @mtp_y <= 477
  681.     # $game_screen.pictures[41].show("变", 0, 398, 452, 100.0, 100.0, 255, 0)
  682.      $game_screen.pictures[40].show("变身1", 0, 388, 430, 100.0, 100.0, 255, 0)
  683.      if Input.trigger?(Input::C)
  684.        $game_system.se_play($data_system.decision_se); $game_screen.pictures[41].erase
  685.       $game_screen.pictures[40].erase
  686.      #  Audio.se_play("Audio/SE/"+"退出",100,100)
  687.       $scene = Scene_Lvup.new
  688.  
  689.       end
  690.     else
  691.       $game_screen.pictures[41].erase
  692.             $game_screen.pictures[40].erase
  693.       end
  694.     if @mtp_x >= 40 and @mtp_x <= 80 and @mtp_y >= 450 and @mtp_y <= 477
  695.    #  $game_screen.pictures[44].show("物品", 0, 402, 452, 100.0, 100.0, 255, 0)
  696.      if Input.trigger?(Input::C)
  697.        $game_system.se_play($data_system.decision_se); $game_screen.pictures[50].erase
  698.    #     Audio.se_play("Audio/SE/"+"退出",100,100)
  699.        #$game_temp.common_event_id = 151
  700.       end
  701.    else
  702.  
  703.    end
  704.  
  705.    ##########################
  706.  
  707.  
  708.     # 坐骑按扭
  709.    if @mtp_x >= 482 and @mtp_x <= 512 and @mtp_y >= 450 and @mtp_y <= 477
  710.     # $game_screen.pictures[46].show("坐骑", 0, 490, 452, 100.0, 100.0, 255, 0)
  711.       $game_screen.pictures[29].show("坐骑11", 0, 476, 430, 100.0, 100.0, 255, 0)
  712.  
  713.      if Input.trigger?(Input::C)
  714.        $game_system.se_play($data_system.decision_se); $game_screen.pictures[46].erase
  715.        $game_screen.pictures[29].erase
  716.     #   Audio.se_play("Audio/SE/"+"退出",100,100)
  717.         $game_temp.common_event_id = 77
  718.  
  719.         $scene = Scene_Troop.new
  720.       end
  721.    else
  722.       $game_screen.pictures[29].erase
  723.        $game_screen.pictures[46].erase
  724.    end
  725.  
  726.     # 状态按扭
  727.  
  728.    if @mtp_x >= 530 and @mtp_x <= 550 and @mtp_y >= 0 and @mtp_y <= 40
  729.    #  $game_screen.pictures[47].show("状态", 0, 542, 452, 100.0, 100.0, 255, 0)
  730.      if Input.trigger?(Input::C)
  731.        $game_system.se_play($data_system.decision_se); $game_screen.pictures[47].erase
  732.       $scene = Scene_Cta.new
  733.    #  Audio.se_play("Audio/SE/"+"退出",100,100)
  734.         #$game_temp.common_event_id =39
  735.          #Scene_Status
  736.       end
  737.    else
  738.      $game_screen.pictures[47].erase
  739.    end
  740.     if @mtp_x >= 550 and @mtp_x <= 640 and @mtp_y >= 0 and @mtp_y <= 40
  741.     # $game_screen.pictures[4].show("状态", 0, 542, 452, 100.0, 100.0, 255, 0)
  742.      if Input.trigger?(Input::B)
  743.        $game_system.se_play($data_system.decision_se); $game_screen.pictures[4].erase
  744.  
  745.         # $game_temp.common_event_id = 280
  746.       end
  747.    else
  748.      $game_screen.pictures[4].erase
  749.    end
  750.  
  751.  
  752.  
  753.  
  754.  
  755.  
  756.  
  757.  
  758.  
  759.  
  760.  
  761.  
  762.  
  763.  
  764.  
  765.  
  766.  
  767.  
  768.  
  769.  
  770.  
  771.  
  772.  
  773.  
  774.  
  775.  
  776.    # 物品按扭
  777.    if @mtp_x >= 308 and @mtp_x <= 326 and @mtp_y >= 450 and @mtp_y <= 477
  778.     # $game_screen.pictures[50].show("物品", 0, 308, 452, 100.0, 100.0, 255, 0)
  779.      $game_screen.pictures[38].show("道具1", 0, 298, 430, 100.0, 100.0, 255, 0)
  780.  
  781.      if Input.trigger?(Input::C)
  782.        $game_system.se_play($data_system.decision_se); $game_screen.pictures[50].erase
  783.         $game_screen.pictures[38].erase
  784.  
  785.     #   Audio.se_play("Audio/SE/"+"退出",100,100)
  786.       $scene = Scene_Item.new
  787.  
  788.       end
  789.    else
  790.      $game_screen.pictures[50].erase
  791.      $game_screen.pictures[38].erase
  792.    end
  793.  
  794.    # 装备按扭
  795.    if @mtp_x >= 332 and @mtp_x <= 362 and @mtp_y >= 450 and @mtp_y <= 477
  796.    #  $game_screen.pictures[48].show("装备", 0, 339, 452, 100.0, 100.0, 255, 0)
  797.      $game_screen.pictures[28].show("装备1", 0, 329, 430, 100.0, 100.0, 255, 0)
  798.      if Input.trigger?(Input::C)
  799.        $game_system.se_play($data_system.decision_se); $game_screen.pictures[48].erase
  800.         $game_screen.pictures[28].erase
  801.       #   Audio.se_play("Audio/SE/"+"拔剑",100,100)
  802.  
  803.         $scene = Scene_Equip.new
  804.  
  805.       # $game_temp.common_event_id =390
  806.     end
  807.    else
  808.      $game_screen.pictures[48].erase
  809.        $game_screen.pictures[28].erase
  810.      end  
  811.  
  812.  
  813.  
  814.    # 小地图按扭
  815.    #if @mtp_x >= 1 and @mtp_x <= 15 and @mtp_y >= 20 and @mtp_y <= 38
  816.    #  $game_screen.pictures[48].show("装备", 0, 339, 452, 100.0, 100.0, 255, 0)
  817.      #$game_screen.pictures[57].show("小地图1", 0, 44, 60, 100.0, 100.0, 255, 0)
  818.      #if Input.trigger?(Input::C)
  819.        #$game_system.se_play($data_system.decision_se); $game_screen.pictures[67].erase
  820.         #$game_screen.pictures[57].erase
  821.       #   Audio.se_play("Audio/SE/"+"拔剑",100,100)
  822.  
  823.  
  824.  
  825.  
  826.  
  827.  
  828.       # $game_temp.common_event_id =390
  829.  
  830.  
  831.     #end   
  832.    #else
  833.      #$game_screen.pictures[57].erase
  834.        #$game_screen.pictures[67].erase
  835.    #end  
  836.  
  837.  
  838.  
  839.  
  840.  
  841.  
  842.  
  843.    # 状态按扭
  844.    if @mtp_x >= 362 and @mtp_x <= 392 and @mtp_y >= 450 and @mtp_y <= 477
  845.     # $game_screen.pictures[37].show("状态", 0, 369, 452, 100.0, 100.0, 255, 0)
  846.       $game_screen.pictures[27].show("状态1", 0, 359, 430, 100.0, 100.0, 255, 0)
  847.      if Input.trigger?(Input::C)
  848.        $game_system.se_play($data_system.decision_se); $game_screen.pictures[37].erase
  849.         $game_screen.pictures[27].erase
  850.      # $game_temp.common_event_id = 80
  851.       $scene = Scene_Dzz.new
  852.      #  Audio.se_play("Audio/SE/"+"轮回",100,100)
  853.      #   $scene = Scene_Status.new
  854.  
  855.  
  856.       end
  857.    else
  858.      $game_screen.pictures[37].erase
  859.           $game_screen.pictures[27].erase
  860.    end
  861.    # 特技按扭
  862.    if @mtp_x >= 452 and @mtp_x <= 482 and @mtp_y >= 450 and @mtp_y <= 477
  863.    #  $game_screen.pictures[49].show("特技", 0, 459, 452, 100.0, 100.0, 255, 0)
  864.       $game_screen.pictures[36].show("特技1", 0, 449, 430, 100.0, 100.0, 255, 0)
  865.      if Input.trigger?(Input::C)
  866.        $game_system.se_play($data_system.decision_se); $game_screen.pictures[49].erase
  867.        $game_screen.pictures[36].erase
  868.       #  Audio.se_play("Audio/SE/"+"拔剑",100,100)
  869.        $scene = Scene_Skill.new
  870.  
  871.       end
  872.    else
  873.      $game_screen.pictures[49].erase
  874.          $game_screen.pictures[36].erase
  875.    end
  876.    # 任务按扭
  877.    if @mtp_x >= 512 and @mtp_x <= 542 and @mtp_y >= 450 and @mtp_y <= 477
  878.     # $game_screen.pictures[45].show("任务", 0, 519, 452, 100.0, 100.0, 255, 0)
  879.       $game_screen.pictures[35].show("任务1", 0, 509, 430, 100.0, 100.0, 255, 0)
  880.      if Input.trigger?(Input::C)
  881.        $game_system.se_play($data_system.decision_se); $game_screen.pictures[45].erase
  882.         $game_screen.pictures[35].erase
  883. #          Audio.se_play("Audio/SE/"+"轮回",100,100)
  884.       $scene = Scene_Task.new
  885.       # $scene=Scene_RecordBook.new
  886.       end
  887.    else
  888.      $game_screen.pictures[45].erase
  889.           $game_screen.pictures[35].erase
  890.    end
  891.    # 存挡按扭
  892.    if @mtp_x >= 572 and @mtp_x <= 612 and @mtp_y >= 450 and @mtp_y <= 477
  893.   #   $game_screen.pictures[44].show("存档", 0, 579, 452, 100.0, 100.0, 255, 0)
  894.      $game_screen.pictures[34].show("存档1", 0, 569, 430, 100.0, 100.0, 255, 0)
  895.      if Input.trigger?(Input::C)
  896.        $game_system.se_play($data_system.decision_se); $game_screen.pictures[44].erase
  897.        $game_screen.pictures[34].erase
  898.       # $scene = Scene_Save.new
  899.    #   Audio.se_play("Audio/SE/"+"轮回",100,100)
  900.         $scene = Scene_Compose.new
  901.     #   $scene = Scene_Loadsave.new
  902.       end
  903.    else
  904.      $game_screen.pictures[44].erase
  905.           $game_screen.pictures[34].erase
  906.    end
  907.    # 读挡按扭
  908.    if @mtp_x >= 542 and @mtp_x <= 572 and @mtp_y >= 450 and @mtp_y <= 477
  909.    #  $game_screen.pictures[43].show("读档", 0, 549, 452, 100.0, 100.0, 255, 0)
  910.       $game_screen.pictures[33].show("读档1", 0, 539, 430, 100.0, 100.0, 255, 0)
  911.      if Input.trigger?(Input::C)
  912.        $game_system.se_play($data_system.decision_se); $game_screen.pictures[43].erase
  913.        $game_screen.pictures[33].erase
  914.       # $scene = Scene_Load.new
  915.      #  Audio.se_play("Audio/SE/"+"退出",100,100)
  916.        #$game_temp.common_event_id = 184
  917.         $scene = Scene_Status.new
  918.  
  919.       end
  920.    else
  921.      $game_screen.pictures[43].erase
  922.           $game_screen.pictures[33].erase
  923.    end
  924.    # 退出按扭
  925.    if @mtp_x >= 612 and @mtp_x <= 642 and @mtp_y >= 450 and @mtp_y <= 477
  926.     # $game_screen.pictures[42].show("退出", 0, 609, 450, 100.0, 100.0, 255, 0)
  927.        $game_screen.pictures[32].show("退出1", 0, 602, 430, 100.0, 100.0, 255, 0)
  928.      if Input.trigger?(Input::C)
  929.        $game_system.se_play($data_system.decision_se); $game_screen.pictures[42].erase
  930.        $game_screen.pictures[32].erase
  931.     #   Audio.se_play("Audio/SE/"+"轮回",100,100)
  932.       # $scene = Scene_End.new
  933.       $scene = Scene_Dz.new
  934.  
  935.  
  936.       end
  937.    else
  938.      $game_screen.pictures[42].erase
  939.           $game_screen.pictures[32].erase
  940.         end
  941.  
  942.  
  943.  
  944.  
  945.  
  946.    # 地图界面按扭操作系统★★★★★★★★★★★★★★★★★★★★★
  947.    unless $game_system.map_interpreter.running? and @mouse_sta == 2 #鼠标状态不为跟随状态
  948.      #得到鼠标图标方向
  949.      $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)
  950.   else
  951.      #令鼠标图标为正常
  952.      $mouse_icon_id = 0 if @mouse_sta != 2
  953.    end
  954.    #if Mouse.trigger?(Mouse::LEFT)
  955.    if Mouse.press?(Mouse::LEFT) && $game_player.move_key == true #★★★★★
  956.    #if Mouse.trigger?(Mouse::LEFT) && $game_player.move_key == true #★★★★★     
  957.  
  958.      unless $game_system.map_interpreter.running? or
  959.             # 地图界面按扭操作系统★★★★★★★★★★★★★★★★★★★★★
  960.             @move_route_forcing or $game_temp.message_window_showing or @mtp_y >= 438
  961.             # 地图界面按扭操作系统★★★★★★★★★★★★★★★★★★★★★
  962.        #初始化
  963.        @mouse_sta = 1
  964.        p_direction = 5
  965.        #检查鼠标处能否开启事件
  966.        event_start,p_direction = $game_map.check_event_custom_start(mouse_x, mouse_y)
  967.        #若在移动中再次点击鼠标左键(即双击左键),则改鼠标状态为跟随状态
  968.        @mouse_sta = 2 if @paths_id != nil and @paths_id != @paths.size
  969.        if @mouse_sta != 2
  970.          #鼠标状态不为跟随状态则取数据并初始化路径
  971.          trg_x = (mouse_x + $game_map.display_x / 4) / 32
  972.          trg_y = (mouse_y + $game_map.display_y / 4) / 32
  973.          @paths = []
  974.          @paths_id = 0
  975.          if event_start == 0 #若不能开启事件
  976.            if trg_x != $game_player.x or trg_y != $game_player.y #若目标不为自身则开始寻路
  977.              find_path = Find_Path.new
  978.              @paths = find_path.find_player_short_path(trg_x, trg_y, @mtp_x, @mtp_y)
  979.            end
  980.          else #若能开启事件则改变角色朝向
  981.            @direction = p_direction
  982.          end
  983.        end
  984.      end
  985.    end
  986.    #开始移动
  987.    if @mouse_sta != nil and @mouse_sta == 1 #若鼠标状态为寻路状态
  988.  
  989.      unless moving? or $game_system.map_interpreter.running? or
  990.             @move_route_forcing or $game_temp.message_window_showing #排除无效情况
  991.        if @paths_id != nil and @paths != nil and @paths_id <= @paths.size #若没有完成路径
  992.          case @paths[@paths_id] #判断路径
  993.          when 6
  994.            @last_move_x = true
  995.            move_right
  996.            @paths_id += 1
  997.            @direction = 6
  998.          when 4
  999.            @last_move_x = true
  1000.            move_left
  1001.            @paths_id += 1
  1002.            @direction = 4
  1003.          when 2
  1004.            @last_move_x = false
  1005.            move_down
  1006.            @direction = 2
  1007.            @paths_id += 1
  1008.          when 8
  1009.            @last_move_x = false
  1010.            move_up
  1011.            @direction = 8
  1012.            @paths_id += 1
  1013.          #斜四方向
  1014.          when 1
  1015.            @last_move_x = false
  1016.            move_lower_left
  1017.            @direction = 1
  1018.            @paths_id += 1
  1019.          when 3
  1020.            @last_move_x = false
  1021.            move_lower_right
  1022.            @direction = 3
  1023.            @paths_id += 1
  1024.          when 7
  1025.            @last_move_x = false
  1026.            move_upper_left
  1027.            @direction = 7
  1028.            @paths_id += 1
  1029.          when 9
  1030.            @last_move_x = false
  1031.            move_upper_right
  1032.            @direction = 9
  1033.            @paths_id += 1
  1034.          end
  1035.        end
  1036.      end
  1037.  
  1038.  
  1039.  
  1040.  
  1041.  
  1042.  
  1043.  
  1044.  
  1045.  
  1046.  
  1047.  
  1048.  
  1049.  
  1050.  
  1051.  
  1052.  
  1053.  
  1054.  
  1055.  
  1056.  
  1057.  
  1058.  
  1059.  
  1060.  
  1061.  
  1062.  
  1063.  
  1064.  
  1065.  
  1066.  
  1067.  
  1068.  
  1069.    elsif @paths != nil and @mouse_sta == 2 #当鼠标状态为跟随,且在移动中
  1070.  
  1071.  
  1072.  
  1073.  
  1074.  
  1075.  
  1076.  
  1077.      #if Mouse.press?( Mouse::LEFT ) #持续按住鼠标
  1078.      if Mouse.press?(Mouse::LEFT) && $game_player.move_key == true #★★★★★     
  1079.  
  1080.        unless moving? or $game_system.map_interpreter.running? or
  1081.               @move_route_forcing or $game_temp.message_window_showing #排除无效情况
  1082.          #跟随方向判断并跟随
  1083.          rate =  $game_map.show_rate(self)
  1084.          width = (RPG::Cache.character(self.character_name,self.character_hue).width / 8) * rate
  1085.          height = (RPG::Cache.character(self.character_name,self.character_hue).height / 8) * rate
  1086.          self_ox = (self.screen_x - width / 2 + self.screen_x + width / 2) / 2
  1087.          self_oy = (self.screen_y - height + self.screen_y) / 2
  1088.          if (@mtp_x - self_ox)*(@mtp_x - self_ox) + (@mtp_y - self_oy)*(@mtp_y - self_oy) >= 961
  1089.            if @mtp_x > self_ox
  1090.              if self_oy - @mtp_y < 0.4 * (@mtp_x - self_ox) and
  1091.                 @mtp_y - self_oy < 0.4 * (@mtp_x - self_ox)
  1092.                move_right
  1093.                $mouse_icon_id = 16
  1094.                @direction = 6
  1095.              end
  1096.              if @mtp_y - self_oy > - 0.4 * ( self_ox - @mtp_x ) and
  1097.                 @mtp_y - self_oy < - 2.4 * ( self_ox - @mtp_x )
  1098.                move_lower_right
  1099.                $mouse_icon_id = 13
  1100.                @direction = 3
  1101.              end
  1102.              if @mtp_y - self_oy < 0.4 * ( self_ox - @mtp_x ) and
  1103.                 @mtp_y - self_oy > 2.4 * ( self_ox - @mtp_x )
  1104.                move_upper_right
  1105.                $mouse_icon_id = 19
  1106.                @direction = 9
  1107.              end
  1108.              if @mtp_y - self_oy > 2.4 * ( @mtp_x - self_ox )
  1109.                move_down
  1110.                $mouse_icon_id = 12
  1111.                @direction = 2
  1112.              end
  1113.              if @mtp_y - self_oy < - 2.4 * ( @mtp_x - self_ox )
  1114.                move_up
  1115.                $mouse_icon_id = 18
  1116.                @direction = 8
  1117.              end
  1118.            end
  1119.            if @mtp_x < self_ox
  1120.              if @mtp_y - self_oy > - 0.4 * ( self_ox - @mtp_x ) and
  1121.                 @mtp_y - self_oy < 0.4 * ( self_ox - @mtp_x )
  1122.                move_left
  1123.                $mouse_icon_id = 14
  1124.                @direction = 4
  1125.              end
  1126.              if @mtp_y - self_oy > 0.4 * ( self_ox - @mtp_x ) and
  1127.                 @mtp_y - self_oy < 2.4 * ( self_ox - @mtp_x )
  1128.                move_lower_left
  1129.                $mouse_icon_id = 11
  1130.                @direction = 1
  1131.              end
  1132.              if @mtp_y - self_oy < - 0.4 * ( self_ox - @mtp_x ) and
  1133.                 @mtp_y - self_oy > - 2.4 * ( self_ox - @mtp_x )
  1134.                move_upper_left
  1135.                $mouse_icon_id = 17
  1136.                @direction = 7
  1137.              end
  1138.              if @mtp_y - self_oy > 2.4 * ( self_ox - @mtp_x )
  1139.                move_down
  1140.                $mouse_icon_id = 12
  1141.                @direction = 2
  1142.              end
  1143.              if @mtp_y - self_oy < - 2.4 * ( self_ox - @mtp_x )
  1144.                move_up
  1145.                $mouse_icon_id = 18
  1146.                @direction = 8
  1147.              end
  1148.            end
  1149.          end
  1150.             if @mtp_x > self_ox
  1151.              if @mtp_y - self_oy > - 0.4 * ( @mtp_x - self_ox ) and
  1152.                 @mtp_y - self_oy < 0.4 * ( @mtp_x - self_ox )
  1153.                $mouse_icon_id = 16
  1154.                @direction = 6
  1155.              end
  1156.              if @mtp_y - self_oy > 0.4 * ( @mtp_x - self_ox ) and
  1157.                @mtp_y - self_oy < 2.4 * ( @mtp_x - self_ox )
  1158.                $mouse_icon_id = 13
  1159.                @direction = 3
  1160.              end
  1161.              if @mtp_y - self_oy < - 0.4 * ( @mtp_x - self_ox ) and
  1162.                @mtp_y - self_oy > - 2.4 * ( @mtp_x - self_ox )
  1163.                $mouse_icon_id = 19
  1164.                @direction = 9
  1165.              end
  1166.              if @mtp_y - self_oy > 2.4 * ( @mtp_x - self_ox )
  1167.                $mouse_icon_id = 12
  1168.                @direction = 2
  1169.              end
  1170.              if @mtp_y - self_oy < - 2.4 * ( @mtp_x - self_ox )
  1171.                $mouse_icon_id = 18
  1172.                @direction = 8
  1173.              end
  1174.            end
  1175.            if @mtp_x < self_ox
  1176.              if @mtp_y - self_oy > - 0.4 * ( self_ox - @mtp_x ) and
  1177.                 @mtp_y - self_oy < 0.4 * ( self_ox - @mtp_x )
  1178.                $mouse_icon_id = 14
  1179.                @direction = 4
  1180.              end
  1181.              if @mtp_y - self_oy > 0.4 * ( self_ox - @mtp_x ) and
  1182.                 @mtp_y - self_oy < 2.4 * ( self_ox - @mtp_x )
  1183.                $mouse_icon_id = 11
  1184.                @direction = 1
  1185.              end
  1186.              if @mtp_y - self_oy < - 0.4 * ( self_ox - @mtp_x ) and
  1187.                 @mtp_y - self_oy > - 2.4 * ( self_ox - @mtp_x )
  1188.                $mouse_icon_id = 17
  1189.                @direction = 7
  1190.              end
  1191.              if @mtp_y - self_oy > 2.4 * ( self_ox - @mtp_x )
  1192.                $mouse_icon_id = 12
  1193.                @direction = 2
  1194.              end
  1195.              if @mtp_y - self_oy < - 2.4 * ( self_ox - @mtp_x )
  1196.                $mouse_icon_id = 18
  1197.                @direction = 8
  1198.              end
  1199.            end
  1200.          end
  1201.  
  1202.  
  1203.  
  1204.  
  1205.  
  1206.  
  1207.  
  1208.  
  1209.  
  1210.  
  1211.  
  1212.  
  1213.  
  1214.  
  1215.  
  1216.  
  1217.      else #没状态的情况
  1218.        $mouse_icon_id = 0
  1219.        @mouse_sta = 0
  1220.        @paths_id = @paths.size #终止寻路移动
  1221.      end
  1222.    end
  1223.    self_update
  1224. end
  1225. end
  1226.  
  1227.  
  1228.  
  1229.  
  1230.  
  1231.  
  1232. Mouse.init
  1233. END { Mouse.exit }
  1234. # 八向行走鼠标脚本系列处理★★★★★★★★★★★★★★★★★★★★★★★★★

作者: 芯☆淡茹水    时间: 2015-6-6 22:32
能实现但是比较麻烦。
再者还要除了图片按钮之外,谁知道你那个图片按钮是什么玩意儿,用什么方法显示的,显示的位置又是哪儿,
总得有个判断的依据不是?!
坐等有空的大蛇。




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1