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

Project1

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

[转载] 转载外站一个HUD

[复制链接]

Lv1.梦旅人

梦石
0
星屑
238
在线时间
341 小时
注册时间
2010-9-5
帖子
70
跳转到指定楼层
1
发表于 2014-6-9 12:25:32 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

x
最近看到不少求人物血条的提问,就从外站找了一个比较精美,且简单实用的HUD,分享给大家!
使用方法,将脚本插在main前,并且将以下图片保存在名为Hud的文件夹下,然后保存在Graphics下。
效果图:

人物进入hud遮挡中时,还会透明化

@wind
代码:
RUBY 代码复制
  1. #================================================#
  2. # ¦ ReinoRPG HUD v0.6
  3. # Script: LB
  4. # Translated: Bravo2Kilo
  5. # Toggle key: Kal
  6. #================================================#
  7. puts "HUD Loaded"
  8. module PR_RRPG_HUD
  9.  
  10. #================================================#
  11. #============= General Settings ===============#
  12. #================================================#
  13.   # Post nil if you want to center on screen
  14.   # Place a minus sign in front of value to refer to the opposite side.
  15.   Position_X = 0
  16.   Position_Y = -308
  17.   Bottom_of_the_HUD = "Back.png"
  18.   Bar_HP = "HP.png"
  19.   Bar_MP = "MP.png"
  20.  
  21.   Using_transparency_in_the_entrance = true # Makes the HUD fade when go under it
  22.   Using_transparency_in_the_exit = true # FadeOut to disappear in just
  23.  
  24.   Speed = 3 # Speed to FadeIn/FadeOut
  25.   Final_Opacity = 255 # Final 0pacity of the HUD
  26.   Opacity_Final_Element = 255 # Opacity of the final elements of the HUD
  27.   Character_Opacity = 150 # Opacity if the character is under
  28.   Opacity_Character_Element = 160 # Opacity of the elements
  29.  
  30.   Switch_Control = 1 # Switch that controls whether the HUD is active or not
  31.                                          # HUD to be active ON and OFF to turn it off.
  32.  
  33.   Number_Character = 1 # The number of character in order according to menu
  34.  
  35.   HUD_Toggle_Show_Key = Input::L # Press this key to show/hide the HUD
  36.                                                                  # L is the Q key on a keyboard.
  37.                                                                  # Press F1 in a game to see what the default
  38.                                                                  # key mappings are.
  39.  
  40. #==============================================#
  41. #=============== HUD Elements ================#
  42. #==============================================#
  43.  
  44.   # Set to true to display graphic charset (false to not display)
  45.   Char_Show = true
  46.   Char_X = 46
  47.   Char_Y = 66
  48.  
  49.   # Set true to show the character's name (false to not display)
  50.   Name_Show = true
  51.   Name_Alignment = 1 # 0 = Left | 1 = Center | 2 = Right
  52.   Name_X = 92
  53.   Name_Y = 25
  54.   Name_Width = 134
  55.   Name_Color = Color.new(255,255,255)
  56.   Name_Font = nil # Font to use, write nil to use the default
  57.   Name_Size_of_Font = 17 # Size_of Font
  58.  
  59.   # Set true to show the character's class (false to not display)
  60.   Class_Show = true
  61.   Class_Alignment = 0 # 0 = Left | 1 = Center | 2 = Right
  62.   Class_X = 229
  63.   Class_Y = 25
  64.   Class_Width = 60
  65.   Class_Color = Color.new(255,255,255)
  66.   Class_Font = nil # Font to use, write nil to use the default
  67.   Class_Size_of_Font = 16 # Size_of Font
  68.  
  69.   # Set true to show the bar that represents the character's HP (false to not display)
  70.   HP_Show = true
  71.   HP_X = 92
  72.   HP_Y = 42
  73.  
  74.   # Set true to show the bar that represents the character's MP (false to not display)
  75.   MP_Show = true
  76.   MP_X = 92
  77.   MP_Y = 59
  78.  
  79.   # Set true to show the value of Current HP bar (false to not display)
  80.   Values_HP_Show_Current = false
  81.   # Set true to show the maximum value of the HP bar (false to not display)
  82.   Values_HP_Show_Total = false
  83.   Values_HP_Color = Color.new(255,255,255)
  84.   Values_HP_Font = nil # Font to use, write nil to use the default
  85.   Values_HP_Size_of_Font = 14 # Size_of Font
  86.   Values_HP_X = 92
  87.   Values_HP_Y = 38
  88.  
  89.   # Set true to show the value of Current MP bar (false to not display)
  90.   Values_MP_Show_Current = false
  91.   # Set true to show the maximum value of the MP bar (false to not display)
  92.   Values_MP_Show_Total = false
  93.   Values_MP_Color = Color.new(255,255,255)
  94.   Values_MP_Font = nil # Font to use, write nil to use the default
  95.   Values_MP_Size_of_Font = 14 # Size_of Font
  96.   Values_MP_X = 92
  97.   Values_MP_Y = 55
  98.  
  99.   # Set true to show the character's level (false to not display)
  100.   LV_Show = true
  101.   LV_Color = Color.new(255,255,255)
  102.   LV_Font = nil # Font to use, write nil to use the default
  103.   LV_Size_of_Font = 19 # Size_of Font
  104.   LV_Width = 30
  105.   LV_X = 241
  106.   LV_Y = 49
  107.  
  108.   # Set true to show the character of money (false to not display)
  109.   Gold_Show = true
  110.   Gold_Color = Color.new(255,255,255)
  111.   Gold_Font = nil # Font to use, write nil to use the default
  112.   Gold_Size_of_Font = 18 # Size_of Font
  113.   Gold_X = 281
  114.   Gold_Y = 35
  115.   Gold_Width = 50
  116.  
  117.   # Set true to show the suffix of play money (false to not display)
  118.   Text_Show = true
  119.   Text_Color = Color.new(255,255,255)
  120.   Text_Font = nil # Font to use, write nil to use the default
  121.   Text_Size_of_Font = 15 # Size_of Font
  122.   Text_X = 281
  123.   Text_Y = 50
  124.   Text_Width = 50
  125.   Text = "Gold" # Name of game currency
  126. end
  127. #===============================================#
  128. #============ End of Settings ================#
  129. #===============================================#
  130. #============ Top of Script ==================#
  131. #===============================================#
  132. module Cache
  133.   #--------------------------------------------------------------------------
  134.   # * Get HUD Graphic
  135.   # filename : Filename
  136.   #--------------------------------------------------------------------------
  137.   def self.hud(filename)
  138.         load_bitmap("Graphics/Hud/", filename)
  139.   end
  140. end
  141. class Scene_Map < Scene_Base
  142.   include PR_RRPG_HUD
  143.  
  144.   alias hud_start start
  145.   alias hud_update update
  146.   alias hud_terminate terminate
  147.  
  148.   def start
  149.         active_hud
  150.         hud_start
  151.   end
  152.  
  153.   def active_hud
  154.         unless @hud_has_run_before
  155.           $game_switches[Switch_Control] = true
  156.           @hud_has_run_before = true
  157.         end
  158.         @animation_hud1 = Using_transparency_in_the_entrance
  159.         @animation_hud2 = Using_transparency_in_the_entrance
  160.         @animation_hud_1 = Using_transparency_in_the_exit
  161.         @animation_hud_2 = Using_transparency_in_the_exit
  162.         @back = Sprite.new
  163.         @back.bitmap = Cache.hud(Bottom_of_the_HUD)
  164.         @back.opacity = 0 if @animation_hud1 == true
  165.         x = Position_X
  166.         y = Position_Y
  167.         w = @back.width
  168.         h = @back.height
  169.         x = ( x == nil ? ( 544 - w ) / 2 : ( x < 0 ? ( 544 + x - w ) : x ) )
  170.         y = ( y == nil ? ( 416 - h ) / 2 : ( y < 0 ? ( 416 + y - h ) : y ) )
  171.         @back.x = x
  172.         @back.y = y
  173.         @back.z = 190
  174.         @wind = Window_Base.new(x-16,y-16,w+32,h+32)
  175.         @wind.opacity = 0
  176.         @wind.contents_opacity = 0 if @animation_hud2 == true
  177.         @wind.z = 195
  178.         @wind.contents.font.shadow = false
  179.         @id = Number_Character-1
  180.         @info = []
  181.         @hp = Sprite.new
  182.         @hp.bitmap = Bitmap.new(32,32)
  183.         @mp = Sprite.new
  184.         @mp.bitmap = Bitmap.new(32,32)
  185.         @hp.x = HP_X + x
  186.         @mp.x = MP_X + x
  187.         @hp.y = HP_Y + y
  188.         @mp.y = MP_Y + y
  189.         @hp.z = 192
  190.         @mp.z = 193
  191.         @hp.opacity = 0 if @animation_hud2 == true
  192.         @mp.opacity = 0 if @animation_hud2 == true
  193.         hud_real_update if status_update
  194.   end
  195.  
  196.   def terminate
  197.         if @animation_hud_1 == true
  198.           @back.bitmap.dispose
  199.           @back.dispose
  200.         end
  201.         if @animation_hud_2 == true
  202.           @hp.bitmap.dispose
  203.           @hp.dispose
  204.           @mp.bitmap.dispose
  205.           @mp.dispose
  206.           @wind.contents.dispose
  207.           @wind.dispose
  208.         end
  209.         hud_terminate
  210.   end
  211.  
  212.   def update
  213.         if $game_switches[Switch_Control] == true and @hud_keyboard_switch
  214.           if @back != nil
  215.                 if @back.opacity < Final_Opacity and @animation_hud1 == true
  216.                   @back.opacity += Speed
  217.                 else
  218.                   @back.opacity = Final_Opacity
  219.                   @animation_hud1 = false
  220.                 end
  221.                 if @wind.contents_opacity < Opacity_Final_Element and @animation_hud2 == true
  222.                   @wind.contents_opacity += Speed
  223.                   @hp.opacity += Speed
  224.                   @mp.opacity += Speed
  225.                 else
  226.                   @wind.contents_opacity = Opacity_Final_Element
  227.                   @hp.opacity = Opacity_Final_Element
  228.                   @mp.opacity = Opacity_Final_Element
  229.                   @animation_hud2 = false
  230.                 end
  231.           else
  232.                 active_hud
  233.           end
  234.         else
  235.           if @back != nil
  236.                 if @back.opacity > Speed-1 and @animation_hud_1 == true
  237.                   @back.opacity -= Speed
  238.                 else
  239.                   @back.bitmap.dispose
  240.                   @back.dispose
  241.                   @back = nil
  242.                   @animation_hud_1 = false
  243.                 end
  244.                 if @wind.contents_opacity > Speed-1 and @animation_hud_2 == true
  245.                   @wind.contents_opacity -= Speed
  246.                   @hp.opacity -= Speed
  247.                   @mp.opacity -= Speed
  248.                 else
  249.                   if @animation_hud_2 == true
  250.                         @hp.bitmap.dispose
  251.                         @hp.dispose
  252.                         @hp = nil
  253.                         @mp.bitmap.dispose
  254.                         @mp.dispose
  255.                         @mp = nil
  256.                         @wind.contents.dispose
  257.                         @wind.dispose
  258.                         [url=home.php?mod=space&uid=37259]@wind[/url] = nil
  259.                         @animation_hud_2 = false
  260.                   end
  261.                 end
  262.           end
  263.         end
  264.         if @back != nil
  265.           if $game_player.screen_x >= @back.x and $game_player.screen_x <= @back.x + @back.width and
  266.                  $game_player.screen_y >= @back.y and $game_player.screen_y <= @back.y + @back.height
  267.                 @back.opacity = Character_Opacity
  268.                 @hp.opacity = Opacity_Character_Element
  269.                 @mp.opacity = Opacity_Character_Element
  270.                 @wind.contents_opacity = Opacity_Character_Element
  271.           end
  272.         end
  273.         hud_real_update if status_update
  274.         hud_check_key_toggle
  275.         hud_update
  276.   end
  277.  
  278.   def hud_real_update
  279.         a = $game_party.members[@id]
  280.         @wind.contents.clear
  281.         @wind.draw_character(a.character_name, a.character_index, Char_X, Char_Y) if Char_Show
  282.         if Name_Show
  283.           @wind.contents.font.name = Name_Font if Name_Font != nil
  284.           @wind.contents.font.color = Name_Color
  285.           @wind.contents.font.size = Name_Size_of_Font
  286.           @wind.contents.draw_text(Name_X, Name_Y, Name_Width, Name_Size_of_Font, a.name, Name_Alignment)
  287.         end
  288.         if Class_Show
  289.           @wind.contents.font.name = Class_Font if Class_Font != nil
  290.           @wind.contents.font.color = Class_Color
  291.           @wind.contents.font.size = Class_Size_of_Font
  292.           @wind.contents.draw_text(Class_X, Class_Y, Class_Width, Class_Size_of_Font, a.class.name, Class_Alignment)
  293.         end
  294.         if HP_Show
  295.           @hp.bitmap.dispose
  296.           @hp.bitmap = Cache.hud(Bar_HP)
  297.           @hp.bitmap.clear_rect(Rect.new((@hp.width*a.hp/a.mhp),0,@hp.width,@hp.height))
  298.         end
  299.         if MP_Show
  300.           @mp.bitmap.dispose
  301.           @mp.bitmap = Cache.hud(Bar_MP)
  302.           @mp.bitmap.clear_rect(Rect.new((@mp.width*a.mp/a.mmp),0,@mp.width,@mp.height))
  303.         end
  304.         if Values_HP_Show_Current
  305.           text = a.hp.to_s
  306.         end
  307.         if Values_HP_Show_Total
  308.           text = a.mhp.to_s
  309.         end
  310.         if Values_HP_Show_Current and Values_HP_Show_Total
  311.           text = a.hp.to_s + "/" + a.mhp.to_s
  312.         end
  313.         if text != nil
  314.           @wind.contents.font.name = Values_HP_Font if Values_HP_Font != nil
  315.           @wind.contents.font.color = Values_HP_Color
  316.           @wind.contents.font.size = Values_HP_Size_of_Font
  317.           @wind.contents.draw_text(Values_HP_X, Values_HP_Y, @hp.width, Values_HP_Size_of_Font, text, 2)
  318.         end
  319.         text = nil
  320.         if Values_MP_Show_Current
  321.           text = a.mp.to_s
  322.         end
  323.         if Values_MP_Show_Total
  324.           text = a.mmp.to_s
  325.         end
  326.         if Values_MP_Show_Current and Values_MP_Show_Total
  327.           text = a.mp.to_s + "/" + a.mmp.to_s
  328.         end
  329.         if text != nil
  330.           @wind.contents.font.name = Values_MP_Font if Values_MP_Font != nil
  331.           @wind.contents.font.color = Values_MP_Color
  332.           @wind.contents.font.size = Values_MP_Size_of_Font
  333.           @wind.contents.draw_text(Values_MP_X, Values_MP_Y, @hp.width, Values_MP_Size_of_Font, text, 2)
  334.         end
  335.         if LV_Show
  336.           @wind.contents.font.name = LV_Font if LV_Font != nil
  337.           @wind.contents.font.color = LV_Color
  338.           @wind.contents.font.size = LV_Size_of_Font
  339.           @wind.contents.draw_text(LV_X, LV_Y, LV_Width, LV_Size_of_Font, a.level, 1)
  340.         end
  341.         if Gold_Show
  342.           @wind.contents.font.name = Gold_Font if Gold_Font != nil
  343.           @wind.contents.font.color = Gold_Color
  344.           @wind.contents.font.size = Gold_Size_of_Font
  345.           @wind.contents.draw_text(Gold_X, Gold_Y, Gold_Width, Gold_Size_of_Font, $game_party.gold, 1)
  346.         end
  347.         if Text_Show
  348.           @wind.contents.font.name = Text_Font if Text_Font != nil
  349.           @wind.contents.font.color = Text_Color
  350.           @wind.contents.font.size = Text_Size_of_Font
  351.           @wind.contents.draw_text(Text_X, Text_Y, Text_Width, Text_Size_of_Font, Text, 1)
  352.         end
  353.   end
  354.  
  355.   def status_update
  356.         return false if [url=home.php?mod=space&uid=37259]@wind[/url] == nil
  357.         a = $game_party.members[@id]
  358.         return update_infos if a.id != @info[0]
  359.         return update_infos if a.character_name != @info[1]
  360.         return update_infos if a.character_index != @info[2]
  361.         return update_infos if a.name != @info[3]
  362.         return update_infos if a.class_id != @info[4]
  363.         return update_infos if a.class.name != @info[5]
  364.         return update_infos if a.hp != @info[6]
  365.         return update_infos if a.mhp != @info[7]
  366.         return update_infos if a.mp != @info[8]
  367.         return update_infos if a.mmp != @info[9]
  368.         return update_infos if a.level != @info[10]
  369.         return update_infos if $game_party.gold != @info[11]
  370.         return false
  371.   end
  372.  
  373.   def update_infos
  374.         a = $game_party.members[@id]
  375.         @info[0] = a.id
  376.         @info[1] = a.character_name
  377.         @info[2] = a.character_index
  378.         @info[3] = a.name
  379.         @info[4] = a.class_id
  380.         @info[5] = a.class.name
  381.         @info[6] = a.hp
  382.         @info[7] = a.mhp
  383.         @info[8] = a.mp
  384.         @info[9] = a.mmp
  385.         @info[10] = a.level
  386.         @info[11] = $game_party.gold
  387.         return true
  388.   end
  389.   def hud_check_key_toggle
  390.         @hud_keyboard_switch = true if @hud_keyboard_switch.nil?
  391.         if Input.trigger?(HUD_Toggle_Show_Key)
  392.           @hud_keyboard_switch = !@hud_keyboard_switch
  393.         end
  394.   end
  395.  
  396. end

其中,174行为:        @wind = Window_Base.new(x-16,y-16,w+32,h+32)
需要保存的图片:



另外,给出一个范例:
hud.rar (1.48 MB, 下载次数: 115)      

点评

可以先@一下出问题的那个变量名,已编辑  发表于 2014-6-11 16:15
我說LZ的=3=|||  发表于 2014-6-10 21:41
Saber?  发表于 2014-6-10 20:29
你的頭像有高清版麼=.=:  发表于 2014-6-10 20:28
好的素材能拯救世界  发表于 2014-6-9 12:56

评分

参与人数 2星屑 +25 收起 理由
david95 + 15 精品文章
喜阳阳 + 10 塞糖

查看全部评分

点击即可领养:

Lv1.梦旅人

梦石
0
星屑
65
在线时间
38 小时
注册时间
2013-11-23
帖子
12
2
发表于 2014-6-9 14:01:22 | 只看该作者
脚本Hud的174行发生了语法错误
而且你给的范例根本打不开。。。。。。

点评

[url=home.php?mod=space&uid=37259]@wind[/url] = Window_Base.new(x-16,y-16,w+32,h+32)改成 @wind = Window_Base.new(x-16,y-16,w+32,h+32) 范例打不开可能是楼主删了DLL。  发表于 2014-6-9 14:12
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
238
在线时间
341 小时
注册时间
2010-9-5
帖子
70
3
 楼主| 发表于 2014-6-9 14:07:54 | 只看该作者
zt121670670 发表于 2014-6-9 14:01
脚本Hud的174行发生了语法错误
而且你给的范例根本打不开。。。。。。 ...

我的范例打开无误,自己又测试了一遍
至于脚本错误,那是论坛bug,和我木有关系
怎么改你自己会吧?
点击即可领养:
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
70
在线时间
80 小时
注册时间
2014-4-12
帖子
167
4
发表于 2014-6-10 15:54:06 | 只看该作者
还行,不过还是差了点,不过好像跟我的脚本一样不支持鼠标(这好像也不需要支持鼠标)好吧,我承认,我想到我那个hud的一个功能了
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-4-24 07:07

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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