Project1
标题: 怎样使图片显示生命的脚本改成从上至下减少? [打印本页]
作者: 南宫爱 时间: 2011-7-22 10:29
标题: 怎样使图片显示生命的脚本改成从上至下减少?
用了这个脚本:(怎样使它从上至下减少(垂直),而不是从右至左减少(水平))- #======================================
- # ■ 图片显示生命
- #======================================
- # 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 = 998
- 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) #经验条
- 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
复制代码