搜索附件  

地图显示HP SP 条.rar

 

地图显示HP条,SP条,金钱等:



不会的直接下载范例
RUBY 代码
  1. #==============================================================================
  2. # ■地图显示HP/SP槽 + 金钱数量
  3. # -by:戴迪
  4. # -2017.6.17
  5. # -本人首个脚本......大触轻喷
  6. #------------------------------------------------------------------------------
  7. #此脚本结构简单,可供比我还新的人学习- -
  8. #此脚本可自行更改HP/SP槽的大小,颜色,显示的坐标,
  9. #有能力的还可自行添加EXP,等级显示等
  10. #HP/SP槽比较简易,本人在思考如何美化
  11. #------------------------------------------------------------------------------
  12. #使用方法:
  13. #1.在Main之前插入此脚本,
  14. #
  15. #2.在Scene_Map里,找到"●主处理下"的       # 生成信息窗口,添加
  16. #     @mapshow = Window_Mapshow.new
  17. #     @mapshow.opacity = 60   #-------------------------------更改窗口透明度
  18. #
  19. #   再往下滑,找到                         # 释放信息窗口,添加
  20. #          @mapshow.dispose
  21. #
  22. #   再往下滑.....找到"●刷新画面"下的      #刷新信息窗口,添加
  23. #     @mapshow.update
  24. #
  25. #   完毕.
  26. #   
  27. #==============================================================================
  28. # ■ Window_Mapshow
  29. #------------------------------------------------------------------------------
  30. #  显示血条的窗口。
  31. #==============================================================================
  32. class Window_Mapshow < Window_Base
  33.   Hide_Window_Mapshow = 33                    #-----控制窗口的开关为33号开关
  34.   #--------------------------------------------------------------------------
  35.   # ● 初始化窗口
  36.   #--------------------------------------------------------------------------
  37.   def initialize
  38.     super(0, 0, 640, 40 + 32)
  39.     self.contents = Bitmap.new(width - 32, height - 32)
  40.     refresh
  41.   end
  42.   #--------------------------------------------------------------------------
  43.   # ● 描绘HP槽
  44.   #--------------------------------------------------------------------------
  45.   def draw_actor_hp_bar(actor, x, y,width = 200)
  46.     self.contents.fill_rect(36,4,width + 4,24,Color.new(255,255,255,255))
  47.     self.contents.fill_rect(36 + 2,4 + 2,width ,20,Color.new(0,0,0,255))
  48.     w1 = (1.0 * $game_party.actors[0].hp  / $game_party.actors[0].maxhp) * width
  49.     self.contents.fill_rect(36 + 2,4 + 2,w1 ,20,Color.new(200,0,0,255))
  50.   end
  51.   #--------------------------------------------------------------------------
  52.   # ● 描绘SP槽
  53.   #--------------------------------------------------------------------------
  54.   def draw_actor_sp_bar(actor, x, y,width = 200)
  55.     self.contents.fill_rect(36 + 240 ,4,width + 4,24,Color.new(255,255,255,255))
  56.     self.contents.fill_rect(36 + 2 + 240 ,4 + 2,width ,20,Color.new(0,0,0,255))
  57.     w2 = (1.0 * $game_party.actors[0].sp / $game_party.actors[0].maxsp) * width
  58.     self.contents.fill_rect(36 + 2 + 240,4 + 2,w2 ,20,Color.new(248,112,0,255))
  59.   end
  60.   #--------------------------------------------------------------------------
  61.   # ● 描绘金钱数目
  62.   #--------------------------------------------------------------------------
  63.   def draw_actor_gold(actor, x, y,width = 200)
  64.     cx = contents.text_size($data_system.words.gold).width  #cx = 11
  65.     self.contents.font.color = normal_color
  66.     self.contents.draw_text(538, 0, 64-cx-2 ,32, $game_party.gold.to_s, 2)
  67.     self.contents.font.color = system_color
  68.     self.contents.draw_text(600-cx, 0, cx, 32, $data_system.words.gold, 2)
  69.   end
  70.   #--------------------------------------------------------------------------
  71.   # ● 刷新--通常在这绘制位图
  72.   #--------------------------------------------------------------------------
  73.   def refresh
  74.     self.contents.clear
  75.     draw_actor_hp_bar($game_party.actors[0], 0, 20)
  76.     draw_actor_sp_bar($game_party.actors[0], 0, 20)
  77.     draw_actor_gold($game_party.gold.to_s, 0, 20)
  78.     self.contents.font.color = Color.new(255,255,255,255)
  79.     self.contents.draw_text(0,0 , 36, 32, "HP:")
  80.     self.contents.draw_text(70,0 , 36, 32,$game_party.actors[0].hp.to_s)
  81.     self.contents.draw_text(70 + 63,0 + 1, 36, 32, "/")
  82.     self.contents.draw_text(70 + 63 + 42,0 + 1, 36, 32,$game_party.actors[0].maxhp.to_s)
  83.     self.contents.draw_text(0 + 240,0 , 36, 32, "SP:")
  84.     self.contents.draw_text(70 + 240,0 , 36, 32,$game_party.actors[0].sp.to_s)
  85.     self.contents.draw_text(70 + 63 + 240,0 + 1, 36, 32, "/")
  86.     self.contents.draw_text(70 + 105 + 240,0 + 1, 36, 32,$game_party.actors[0].maxsp.to_s)
  87.   end
  88.   def update
  89.     super
  90.     self.visible = !$game_switches[Hide_Window_Mapshow]
  91.     returnunlessself.visible                 #-----unless相当于if not
  92.     rest_hp = $game_party.actors[0].hp
  93.     max_hp = $game_party.actors[0].maxhp
  94.     rest_sp = $game_party.actors[0].sp
  95.     max_sp = $game_party.actors[0].maxsp
  96.     gold = $game_party.gold
  97.     if$l7_old_hp != rest_hp || ($l7_old_maxhp != max_hp) || $l7_old_sp != rest_sp || ($l7_old_maxsp != max_sp) || $l7_old_gold != gold
  98.        $l7_old_hp = rest_hp
  99.        $l7_old_maxhp = max_hp
  100.        $l7_old_sp = rest_sp
  101.        $l7_old_maxsp = max_sp
  102.        refresh
  103.     end
  104.   end
  105. end
复制代码

RUBY 代码
  1. # 生成信息窗口----------------------------------在此处添加窗口
  2.     @message_window = Window_Message.new
  3.     @mapshow = Window_Mapshow.new
  4.     @mapshow.opacity = 20   #------------------------更改窗口透明度
复制代码

RUBY 代码
  1. # 释放信息窗口--------------------------------记得在此处释放窗口
  2.     @message_window.dispose
  3.     @mapshow.dispose
复制代码

RUBY 代码
  1. # 刷新信息窗口----------------------------记得在此处刷新窗口
  2.     @message_window.update
  3.     @mapshow.update
复制代码

截图



             本帖来自P1论坛作者戴迪,因Project1站服务器在国外有时候访问缓慢不方便作者交流学习,经联系P1站长fux2同意署名转载一起分享游戏制作经验,共同为国内独立游戏作者共同创造良好交流环境,原文地址:https://rpg.blue/forum.php?mod=viewthread&tid=401115  若有侵权,发帖作者可联系底部站长QQ在线咨询功能删除,谢谢。
Loading...

QQ|Archiver|手机版|小黑屋|同能RPG制作大师 ( 沪ICP备12027754号-3 )

GMT+8, 2024-11-22 10:31 , Processed in 0.049955 second(s), 22 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

返回顶部