赞 | 62 |
VIP | 492 |
好人卡 | 47 |
积分 | 42 |
经验 | 71557 |
最后登录 | 2024-5-25 |
在线时间 | 4890 小时 |
Lv3.寻梦者 (版主) /) /)<
- 梦石
- 0
- 星屑
- 4212
- 在线时间
- 4890 小时
- 注册时间
- 2009-2-16
- 帖子
- 8434
|
这个脚本可以在地图上显示HP SP 希望能加一个开关,打开X号开关时,才显示HP SP条 如果没有打开则不显示。(也就是默认不显示)
感谢 这是脚本 由于有点素材 也可以下载范例:
HP.rar
(201.67 KB, 下载次数: 44)
- #======================================
- # ■ 图片显示生命
- #======================================
- # By: pudding
- #======================================
- class Hp_Window < Window_Base
- def initialize
- super(-15, -16, 740, 580)
- self.contents = Bitmap.new(width - 32, height - 32)
- self.opacity = 0
- self.z = 0
- self.visible = true
- refresh
- end
- #--------------------------------------------------------------------------
- # ● 刷新画面
- #--------------------------------------------------------------------------
- def update
- value_x = -188
- actor = $game_party.actors[0] #主角
- draw_hp_background(0 + value_x,0) # HP底图
- draw_mp_background(312 + value_x,8) # MP底图
- draw_hp(actor, 209 + value_x, 8) #生命条
- draw_mp(actor, 312 + value_x, 8) #能量条
- draw_map_exp(actor, 246 + value_x, 29) #经验条
- #角色死亡处理
- if $game_party.actors[0].hp <= 1
- #游戏结束
- $scene = Scene_Gameover.new
- end
- end
- #--------------------------------------------------------------------------
- # ● 刷新画面
- #--------------------------------------------------------------------------
- def refresh
- self.contents.clear
- value_x = -188
- actor = $game_party.actors[0] #主角
- end
- #----------------------------------------------------------------------------
- # ● 底图
- #----------------------------------------------------------------------------
- def draw_hp_background(x,y)
- hp_background = RPG::Cache.picture("HPdi")
- hp_back = Rect.new(0, 0, hp_background.width, hp_background.height)
- self.contents.blt(x, y, hp_background, hp_back)
- end
- def draw_mp_background(x,y)
- hp_background = RPG::Cache.picture("MP")
- hp_back = Rect.new(0, 0, hp_background.width, hp_background.height)
- self.contents.blt(x, y, hp_background, hp_back)
- end
- #----------------------------------------------------------------------------
- # ● 生命条
- #----------------------------------------------------------------------------
- def draw_hp(actor,x,y)
- hp = RPG::Cache.picture("HP条")
- hp_w = hp.width * actor.hp / [actor.maxhp,1].max
- rect2 = Rect.new(0,0,hp_w,hp.height)
- self.contents.blt(x,y,hp,rect2)
- end #def HP
- #----------------------------------------------------------------------------
- # ● 能量条
- #----------------------------------------------------------------------------
- def draw_mp(actor,x,y)
- mp = RPG::Cache.picture("MP条")
- mp_w = mp.width * (actor.maxsp-actor.sp) / [actor.maxsp,1].max
- rect3 = Rect.new(0,0,mp_w,mp.height)
- self.contents.blt(x,y,mp,rect3)
- end #def MP
- #----------------------------------------------------------------------------
- # ● 描绘地图界面经验条
- #----------------------------------------------------------------------------
- def draw_map_exp(actor, x, y)
- bitmap = RPG::Cache.picture("EXP条")
- actor = $game_party.actors[0]
- if actor.nextexp != 0
- jisuan = actor.nowexp.to_f / actor.nextexp
- else
- jisuan = 1
- end
- if actor.level < 99 # 最大等级
- nw = bitmap.width * jisuan
- else
- nw = bitmap.width
- end
- src_rect = Rect.new(0, 0, nw, bitmap.height)
- self.contents.blt( x, y, bitmap, src_rect)
- end
- end
- #==============================================================================
- # ■ Game_Actor
- #==============================================================================
- class Game_Actor
- #--------------------------------------------------------------------------
- # ● 获取目前经验
- #--------------------------------------------------------------------------
- def nowexp
- return @exp - @exp_list[@level]
- end
- #--------------------------------------------------------------------------
- # ● 下一等级还需的经验
- #--------------------------------------------------------------------------
- def nextexp
- return @exp_list[@level+1] > 0 ? @exp_list[@level+1] - @exp_list[@level] : 0
- end
- end
- class Scene_Map
- #--------------------------------------------------------------------------
- # ● 主处理
- #--------------------------------------------------------------------------
- alias fox_text_window_main main
- def main
- @HP_window = Hp_Window.new
- @item_1_new = $game_party.item_number(1).to_s
- @item_2_new = $game_party.item_number(2).to_s
- @item_3_new = $game_party.item_number(3).to_s
- @item_4_new = $game_party.item_number(4).to_s
- fox_text_window_main
- # 释放
- @HP_window.dispose
- if $scene.is_a?(Scene_Title)
- # 淡入淡出画面
- Graphics.transition
- Graphics.freeze
- end
- end
- #--------------------------------------------------------------------------
- # ● 更新
- #--------------------------------------------------------------------------
- alias fox_text_window_update update
- def update
- # 刷新地图状态窗口
- if @item_1_new != $game_party.item_number(1).to_s
- @HP_window.refresh
- @item_1_new = $game_party.item_number(1).to_s
- end
- if @item_2_new != $game_party.item_number(2).to_s
- @HP_window.refresh
- @item_2_new = $game_party.item_number(2).to_s
- end
- if @item_3_new != $game_party.item_number(3).to_s
- @HP_window.refresh
- @item_3_new = $game_party.item_number(3).to_s
- end
- if @item_4_new != $game_party.item_number(4).to_s
- @HP_window.refresh
- @item_4_new = $game_party.item_number(4).to_s
- end
- fox_text_window_update
- if @HP_window.visible
- @HP_window.update
- end
- end
- end
复制代码 |
|