幻想森林

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

[RMXP] 图片层级问题和另外几个问题

[复制链接]

10

主题

85

帖子

258

积分

③业余

脚本万年废柴

积分
258
QQ
发表于 2010-9-7 21:44:37 | 显示全部楼层 |阅读模式
腿神大还在么……柳啊发了一贴无回应
无耻的加入了高亮词……

脚本比较白……最好能举一个相关例子

一、怎样将图片的层级调整到角色层之下、地图层之上
又需要将3张图显示在所有东西的最上面,请问应该修改哪些位置?



二、需要的三张特殊图有两张用到了鼠标响应图片,应该还可以继续调用公共事件吧?
两张图片的显示需要一个开关控制……
第三张是一个通过连续播放图片来形成动画效果的,需要显示在最上层【比前两张图还要高的层级】



三、使用了鼠标系统,怎样禁止鼠标的自动寻路?全部改成由上面的两张图片控制
或者能否推荐一个完全能兼容鼠标响应图片的鼠标脚本【不含有寻路的,只用鼠标】?使用DLL没有关系……

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

使用道具 举报

550

主题

9116

帖子

214748万

积分

超级版主

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

Rank: 8Rank: 8

积分
2147483647
发表于 2010-9-7 22:15:33 | 显示全部楼层
sprite精灵来显示图片。。。事件脚本,配合事件的条件分歧差不多就这样了吧。。。优先级调sprite 的z
我就是你们的神,庶民们,追随我吧!跟着我一起拖后腿!
回复 支持 反对

使用道具 举报

550

主题

9116

帖子

214748万

积分

超级版主

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

Rank: 8Rank: 8

积分
2147483647
发表于 2010-9-7 22:20:35 | 显示全部楼层
你这个脚本有巡路么??我似乎没看到阿。。。
我就是你们的神,庶民们,追随我吧!跟着我一起拖后腿!
回复 支持 反对

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-4-26 12:21 , Processed in 0.034182 second(s), 21 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

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