赞 | 8 |
VIP | 1 |
好人卡 | 0 |
积分 | 96 |
经验 | 29580 |
最后登录 | 2023-4-8 |
在线时间 | 567 小时 |
Lv4.逐梦者
- 梦石
- 7
- 星屑
- 2585
- 在线时间
- 567 小时
- 注册时间
- 2009-4-30
- 帖子
- 271
|
本帖最后由 timmyyayaya 于 2011-12-4 20:09 编辑
不好意思,想请教一下以下这段该如何让图片靠右显示,
- #--------------------------------------------------------------------------
- # * Create HP Number
- #--------------------------------------------------------------------------
- def create_hp_number
- @hp_number_image = RPG::Cache.windowskin("Hud_HP_Number")
- @hp_number_bitmap = Bitmap.new(@hp_number_image.width,@hp_number_image.height)
- @hp_number_sprite = Sprite.new
- @hp_number_sprite.bitmap = @hp_number_bitmap
- @hp_number_sprite.z = 6000#2 + HUD_Z_PRIORITY
- @hp_number_sprite.x = HUD_POS[0] + HP_NUMBER_POS[0]
- @hp_number_sprite.y = HUD_POS[1] + HP_NUMBER_POS[1]
- @im_cw = @hp_number_image.width / 10
- @im_ch = @hp_number_image.height / 2
- @hp_src_rect = Rect.new(@im_cw,0, @im_cw, @im_ch)
- @hp_number_text = @actor.hp.abs.to_s.split(//)
- lowhp2 = @actor.maxhp * 30 / 100
- if @actor.hp < lowhp2
- @health2 = @im_ch
- else
- @health2 = 0
- end
- @hp_health = @health2
- for r in 0..@hp_number_text.size - 1
- @hp_number_abs = @hp_number_text[r].to_i
- @hp_src_rect = Rect.new(@im_cw * @hp_number_abs, @hp_health, @im_cw, @im_ch)
- @hp_number_bitmap.blt(20 + ((@im_cw - 7) * r), 0, @hp_number_image, @hp_src_rect)
- end
- hp_number_refresh
- end
-
复制代码 它是用图片显示数字,
游戏中是默认往左靠,如下:
HP 1245
SP 105
我想请问该如何让它变成:
HP 1245
SP 105
感谢。- #==============================================================================#
- # MOG - Active Hud 2.1 #
- #==============================================================================#
- # By Moghunter #
- # http://www.atelier-rgss.com #
- #==============================================================================#
- # Translated by Calvin624 #
- # http://www.xasabs.wordpress.com #
- #==============================================================================#
- ###############################-DESCRIPTION-####################################
- #==============================================================================#
- # HUD stands for Heads-Up Display. It is a method used in most games to #
- # visually converse with the player. #
- #==============================================================================#
- # Animated HUD System, featuring faces that change according to the action #
- # of the hero. #
- #==============================================================================#
- # #
- # Graphics required: #
- # #
- # Hud_Exp_Meter.png #
- # Hud_Exp_Number #
- # Hud_Face #
- # Hud_HP_Meter #
- # Hud_HP_Number #
- # Hud_Layout #
- # Hud_SP_Meter #
- # Hud_SP_Number #
- # #
- # All images must be in the Windowskin folder. #
- # #
- #==============================================================================#
- # FACES ANIMATIONS INFO: #
- # It takes a picture with the name "Hud_Face.png" and splits it into 5. #
- # Displayed in the following order: #
- # 1 - Normal 2 - Happy 3 - Sad 4 - Action 5 - Tired. #
- #==============================================================================#
- module MOG_ACTIVE_HUD
- # Position of the HUD on the X and Y axis......................[HUD_POSITIONING]
- HUD_POS = [81,415]
- # Position of the HP meter on the X and Y axis.................[HUD_POSITIONING]
- HP_METER_POS = [4,17]
- # Position of the HP number on the X and Y axis................[HUD_POSITIONING]
- HP_NUMBER_POS = [50,14]
- # Position of the SP meter on the X and Y axis.................[HUD_POSITIONING]
- SP_METER_POS = [4,32]
- # Position of the SP number on the X and Y axis................[HUD_POSITIONING]
- SP_NUMBER_POS = [50,29]
- # Position of the EXP meter on the X and Y axis................[HUD_POSITIONING]
- EXP_METER_POS = [65,16]
- # Position of the LV number on the X and Y axis................[HUD_POSITIONING]
- EXP_NUMBER_POS = [65,-5]
- # Position of the Face Graphic on the X and Y axis............[HUD_POSITIONING]
- FACE_POS = [-70,-55]
- # Position of Conditions on the X and Y axis...................[HUD_POSITIONING]
- STATES_POS = [145,40]
- # Position of the Gold indicator ..............................[HUD_POSITIONING]
- GOLD_POS = [0,480]
- # Fade Effect.......................................................[TRUE/FALSE]
- HUD_FADE = true
- # Size of the Active HUD. This influences when the FADE mechanic is turned on.
- HUD_SIZE = [180,110]
- # Enable position of states in relation to character?...............[TRUE/FALSE]
- STATES_POS_CHARACTER = false
- # Display the states with the levitation effect?....................[TRUE/FALSE]
- FLOAT_STATES = true
- # Percentage at which your HP is deemed low.............................[DAMAGE]
- LOWHP = 30
- # Switch ID to disable the HUD..........................................[SWITCH]
- DISABLE_HUD_SWITCH = 5
- # Priority of Hud. (Z)
- HUD_Z_PRIORITY = 5000
- # Element of Tools that do not trigger the face animation in the HUD..................[HUD]
- DISABLE_FACE_ACTION_ID = "P Face Off"
- end
- #==============================================================================
- # ** Game_Actor
- #==============================================================================
- class Game_Actor < Game_Battler
-
- #--------------------------------------------------------------------------
- # * Now Exp
- #--------------------------------------------------------------------------
- def now_exp
- return @exp - @exp_list[@level]
- end
-
- #--------------------------------------------------------------------------
- # * Next Exp
- #--------------------------------------------------------------------------
- def next_exp
- return @exp_list[@level+1] > 0 ? @exp_list[@level+1] - @exp_list[@level] : 0
- end
- end
-
- #==============================================================================
- # ** Interpreter
- #==============================================================================
- class Interpreter
-
- #--------------------------------------------------------------------------
- # ● Display Item Animaton
- #--------------------------------------------------------------------------
- alias active_hud_display_item_animaton display_item_animaton
- def display_item_animaton(damage_item,gold_effect,value,item_name)
- if damage_item == nil
- $game_temp.hud_face_type = 1
- $game_temp.hud_face_refresh = true
- $game_temp.hud_face_time = 0
- $game_temp.hud_face_time2 = 30
- end
- active_hud_display_item_animaton(damage_item,gold_effect,value,item_name)
- end
-
- end
-
- #==============================================================================
- # ** Game_Temp
- #==============================================================================
- class Game_Temp
- attr_accessor :hud_face_type
- attr_accessor :hud_face_type_old
- attr_accessor :hud_face_time
- attr_accessor :hud_face_time2
- attr_accessor :hud_face_refresh
-
- #--------------------------------------------------------------------------
- # * Initialize
- #--------------------------------------------------------------------------
- alias active_hud_initialize initialize
- def initialize
- active_hud_initialize
- @hud_face_type = 0
- @hud_face_type_old = 0
- @hud_face_time = 0
- @hud_face_time2 = 0
- @hud_face_refresh = false
- end
- end
- if $xrxs_xas != nil
- #===============================================================================
- # ■ XAS_ACTION
- #===============================================================================
- module XAS_ACTION
- #--------------------------------------------------------------------------
- # ● Shoot Effect
- #--------------------------------------------------------------------------
- alias active_hud_shoot_effect shoot_effect
- def shoot_effect(action_id,skill)
- active_hud_shoot_effect(action_id,skill)
- if self.battler.is_a?(Game_Actor) and not
- $data_skills[action_id].element_set.include?($data_system.elements.index(MOG_ACTIVE_HUD::DISABLE_FACE_ACTION_ID))
- $game_temp.hud_face_type = 3
- end
- end
- end
- #===============================================================================
- # ■ XRXS_CharacterDamagePop
- #===============================================================================
- module XRXS_CharacterDamagePop
-
- #--------------------------------------------------------------------------
- # ● Display Damage Pop
- #--------------------------------------------------------------------------
- alias xas_active_hud_display_damage_pop display_damage_pop
- def display_damage_pop
- if @battler.is_a?(Game_Actor) and @battler.damage.is_a?(Numeric)
- if @battler.damage > 0
- $game_temp.hud_face_type = 2
- elsif @battler.damage < 0
- $game_temp.hud_face_type = 1
- end
- end
- xas_active_hud_display_damage_pop
- end
- end
- end
- #==============================================================================
- # ** Active_Hud
- #==============================================================================
- class Active_Hud
- include MOG_ACTIVE_HUD
- #--------------------------------------------------------------------------
- # * Initialize
- #--------------------------------------------------------------------------
- def initialize
- @actor = $game_party.actors[0]
- @step = 0
- return if @actor == nil
- setup
- create_layout
- create_face
- create_state
- create_hp_number
- create_hp_meter
- create_sp_number
- create_sp_meter
- create_level_number
- create_level_meter
- create_gold
- update_visible
- end
-
- #--------------------------------------------------------------------------
- # * Setup
- #--------------------------------------------------------------------------
- def setup
- @low_sp = LOWHP
- @low_hp = LOWHP
- @hp = @actor.hp
- @sp = @actor.sp
- @exp = @actor.exp
- @level = @actor.level
- @hp_old = @actor.hp
- @hp_ref = @hp_old
- @hp_refresh = false
- @sp_old = @actor.sp
- @sp_ref = @sp_old
- @sp_refresh = false
- hud_size_x = HUD_SIZE[0]
- hud_size_y = HUD_SIZE[1]
- @oc_range_x = hud_size_x + HUD_POS[0]
- @oc_range_y = hud_size_y + HUD_POS[1]
- end
-
- #--------------------------------------------------------------------------
- # * Create Layout
- #--------------------------------------------------------------------------
- def create_layout
- @layout_sprite = Sprite.new
- @layout_sprite.bitmap = RPG::Cache.windowskin("Hud_Layout")
- @layout_sprite.z = HUD_Z_PRIORITY
- @layout_sprite.x = HUD_POS[0]
- @layout_sprite.y = HUD_POS[1]
- end
-
- #--------------------------------------------------------------------------
- # * Face Exist?
- #--------------------------------------------------------------------------
- def face_exist?(filename)
- return RPG::Cache.windowskin(filename) rescue return false
- end
-
- #--------------------------------------------------------------------------
- # * Icon Exist?
- #--------------------------------------------------------------------------
- def icon_exist?(filename)
- return RPG::Cache.icon(filename) rescue return false
- end
-
- #--------------------------------------------------------------------------
- # * Create Face
- #--------------------------------------------------------------------------
- def create_face
- actor = $game_party.actors[0]
- file_name = actor.name + "_HFace"
- if face_exist?(file_name)
- @face_image = RPG::Cache.windowskin(file_name)
- else
- @face_image = RPG::Cache.windowskin("")
- end
- @face_bitmap = Bitmap.new(@face_image.width,@face_image.height)
- @face_sprite = Sprite.new
- @face_sprite.bitmap = @face_bitmap
- @face_cw = @face_bitmap.width / 5
- @face_ch = @face_bitmap.height
- @face_src_rect_back = Rect.new(@face_cw * $game_temp.hud_face_type, 0,@face_cw , @face_ch)
- @face_bitmap.blt(0,0, @face_image, @face_src_rect_back)
- @face_sprite.z = -1 + HUD_Z_PRIORITY
- @face_sprite.x = HUD_POS[0] + FACE_POS[0]
- @face_sprite.y = HUD_POS[1] + FACE_POS[1]
- if @actor.hp < @actor.maxhp * @low_hp / 100
- $game_temp.hud_face_type = 4
- else
- $game_temp.hud_face_type = 0
- end
- $game_temp.hud_face_time = 10
- end
-
- #--------------------------------------------------------------------------
- # * Create State
- #--------------------------------------------------------------------------
- def create_state
- @states_max = 0
- @states = Sprite.new
- @states.bitmap = Bitmap.new(104,24)
- @states_x = @actor.states.size
- @states_y = 0
- @states_f = false
- sta = []
- for i in @actor.states
- unless @states_max > 3
- sta.push($data_states[i].name)
- if icon_exist?(sta[@states_max])
- image = RPG::Cache.icon(sta[@states_max])
- else
- image = RPG::Cache.icon("")
- end
- cw = image.width
- ch = image.height
- @states.bitmap.blt(26 * @states_max, 0, image, Rect.new(0, 0, cw, ch))
- @states_max += 1
- image.dispose
- end
- end
- if STATES_POS_CHARACTER == true
- @states.x = 5 -(13 * @states_x) + $game_player.screen_x
- @states.y = @states_y + $game_player.screen_y
- else
- @states.x = HUD_POS[0] + STATES_POS[0]
- @states.y = @states_y + HUD_POS[1] + STATES_POS[1]
- end
- @states.z = 1 + HUD_Z_PRIORITY
- end
-
- #--------------------------------------------------------------------------
- # * Create HP Number
- #--------------------------------------------------------------------------
- def create_hp_number
- @hp_number_image = RPG::Cache.windowskin("Hud_HP_Number")
- @hp_number_bitmap = Bitmap.new(@hp_number_image.width,@hp_number_image.height)
- @hp_number_sprite = Sprite.new
- @hp_number_sprite.bitmap = @hp_number_bitmap
- @hp_number_sprite.z = 6000#2 + HUD_Z_PRIORITY
- @hp_number_sprite.x = HUD_POS[0] + HP_NUMBER_POS[0]
- @hp_number_sprite.y = HUD_POS[1] + HP_NUMBER_POS[1]
- @im_cw = @hp_number_image.width / 10
- @im_ch = @hp_number_image.height / 2
- @hp_src_rect = Rect.new(@im_cw,0, @im_cw, @im_ch)
- @hp_number_text = @actor.hp.abs.to_s.split(//)
- lowhp2 = @actor.maxhp * 30 / 100
- if @actor.hp < lowhp2
- @health2 = @im_ch
- else
- @health2 = 0
- end
- @hp_health = @health2
- for r in 0..@hp_number_text.size - 1
- @hp_number_abs = @hp_number_text[r].to_i
- @hp_src_rect = Rect.new(@im_cw * @hp_number_abs, @hp_health, @im_cw, @im_ch)
- @hp_number_bitmap.blt(20 + ((@im_cw - 7) * r), 0, @hp_number_image, @hp_src_rect)
- end
- hp_number_refresh
- end
-
- #--------------------------------------------------------------------------
- # * Create HP Meter
- #--------------------------------------------------------------------------
- def create_hp_meter
- @hp_flow = 0
- @hp_damage_flow = 0
- @hp_image = RPG::Cache.windowskin("Hud_HP")
- @hp_bitmap = Bitmap.new(@hp_image.width,@hp_image.height)
- @hp_range = @hp_image.width / 4
- @hp_width = @hp_range * @actor.hp / @actor.maxhp
- @hp_height = @hp_image.height #/ 2
- @hp_width_old = @hp_width
- @hp_src_rect = Rect.new(@hp_range, 0, @hp_width, @hp_height)
- @hp_bitmap.blt(0,0, @hp_image, @hp_src_rect)
- @hp_sprite = Sprite.new
- @hp_sprite.bitmap = @hp_bitmap
- @hp_sprite.z = 1 + HUD_Z_PRIORITY
- @hp_sprite.x = HUD_POS[0] + HP_METER_POS[0]
- @hp_sprite.y = HUD_POS[1] + HP_METER_POS[1]
- hp_flow_update
- end
-
- #--------------------------------------------------------------------------
- # * Create SP Number
- #--------------------------------------------------------------------------
- def create_sp_number
- @sp_number_image = RPG::Cache.windowskin("Hud_EN_Number")
- @sp_number_bitmap = Bitmap.new(@sp_number_image.width,@sp_number_image.height)
- @sp_number_sprite = Sprite.new
- @sp_number_sprite.bitmap = @sp_number_bitmap
- @sp_number_sprite.z = 6000#2 + HUD_Z_PRIORITY
- @sp_number_sprite.x = HUD_POS[0] + SP_NUMBER_POS[0]
- @sp_number_sprite.y = HUD_POS[1] + SP_NUMBER_POS[1]
- @sp_im_cw = @sp_number_image.width / 10
- @sp_im_ch = @sp_number_image.height / 2
- @sp_src_rect = Rect.new(@sp_im_cw,0, @sp_im_cw, @sp_im_ch)
- @sp_number_text = @actor.sp.abs.to_s.split(//)
- for r in 0..@sp_number_text.size - 1
- @sp_number_abs = @sp_number_text[r].to_i
- @sp_src_rect = Rect.new(@sp_im_cw * @sp_number_abs, 0, @sp_im_cw, @sp_im_ch)
- @sp_number_bitmap.blt(20 + ((@sp_im_cw - 7) * r), 0, @sp_number_image, @sp_src_rect)
- end
- sp_number_refresh
- end
-
- #--------------------------------------------------------------------------
- # * Create SP Meter
- #--------------------------------------------------------------------------
- def create_sp_meter
- @sp_flow = 0
- @sp_damage_flow = 0
- @sp_image = RPG::Cache.windowskin("Hud_EN")
- @sp_bitmap = Bitmap.new(@sp_image.width,@sp_image.height)
- @sp_range = @sp_image.width / 4
- @sp_width = @sp_range * @actor.sp / @actor.maxsp
- @sp_height = @sp_image.height #/ 2
- @sp_width_old = @sp_width
- @sp_src_rect = Rect.new(@sp_range, 0, @sp_width, @sp_height)
- @sp_bitmap.blt(0,0, @sp_image, @sp_src_rect)
- @sp_sprite = Sprite.new
- @sp_sprite.bitmap = @sp_bitmap
- @sp_sprite.z = 1 + HUD_Z_PRIORITY
- @sp_sprite.x = HUD_POS[0] + SP_METER_POS[0]
- @sp_sprite.y = HUD_POS[1] + SP_METER_POS[1]
- sp_flow_update
- end
-
- #--------------------------------------------------------------------------
- # * Create Level Number
- #--------------------------------------------------------------------------
- def create_level_number
- @level_number_image = RPG::Cache.windowskin("Hud_Exp_Number")
- @level_number_bitmap = Bitmap.new(@level_number_image.width,@level_number_image.height)
- @level_number_sprite = Sprite.new
- @level_number_sprite.bitmap = @level_number_bitmap
- @level_number_sprite.z = 2 + HUD_Z_PRIORITY
- @level_number_sprite.x = HUD_POS[0] + EXP_NUMBER_POS[0]
- @level_number_sprite.y = HUD_POS[1] + EXP_NUMBER_POS[1]
- @level_im_cw = @level_number_image.width / 10
- @level_im_ch = @level_number_image.height
- @level_number_text = @actor.level.abs.to_s.split(//)
- for r in 0..@level_number_text.size - 1
- @level_number_abs = @level_number_text[r].to_i
- @level_src_rect = Rect.new(@level_im_cw * @level_number_abs, 0, @level_im_cw, @level_im_ch)
- @level_number_bitmap.blt(13 + ((@level_im_cw - 12) * r), 0, @level_number_image, @level_src_rect)
- end
- end
-
- #--------------------------------------------------------------------------
- # * Create Level Meter
- #--------------------------------------------------------------------------
- def create_level_meter
- @level_image = RPG::Cache.windowskin("Hud_Exp_Meter")
- @level_bitmap = Bitmap.new(@level_image.width,@level_image.height)
- @level_sprite = Sprite.new
- rate = @actor.now_exp.to_f / @actor.next_exp
- rate = 1 if @actor.next_exp == 0
- @level_cw = @level_image.width * rate
- @level_cw = @level_image.width if @actor.level == 99
- @level_src_rect_back = Rect.new(0, 0,@level_cw, @level_image.height)
- @level_bitmap.blt(0,0, @level_image, @level_src_rect_back)
- @level_sprite.bitmap = @level_bitmap
- @level_sprite.z = 1 + HUD_Z_PRIORITY
- @level_sprite.x = HUD_POS[0] + EXP_METER_POS[0]
- @level_sprite.y = HUD_POS[1] + EXP_METER_POS[1]
- end
-
- #--------------------------------------------------------------------------
- # * Create Gold 金錢UI
- #--------------------------------------------------------------------------
- def create_gold
- @gold = $game_party.gold
- @gold_old = @gold
- @gold_ref = @gold_old
- @gold_refresh = false
- # Layout -------------------------------------------------------------------
- @gold_layout_image = RPG::Cache.windowskin("")#XAS_Gold_Layout")
- @gold_layout_bitmap = Bitmap.new(@gold_layout_image.width,@gold_layout_image.height)
- @gold_layout_sprite = Sprite.new
- @gold_layout_sprite.bitmap = @gold_layout_bitmap
- @gold_layout_src_rect_back = Rect.new(0, 0,@gold_layout_image.width, @gold_layout_image.height)
- @gold_layout_bitmap.blt(0,0, @gold_layout_image, @gold_layout_src_rect_back)
- @gold_layout_sprite.z = 5001
- @gold_layout_sprite.x = HUD_POS[0] + GOLD_POS[0]
- @gold_layout_sprite.y = HUD_POS[1] + GOLD_POS[1]
- # Gold ---------------------------------------------------------------------
- @gold_number_image = RPG::Cache.windowskin("")#XAS_Gold_Number")
- @gold_number_bitmap = Bitmap.new(@gold_number_image.width,@gold_number_image.height)
- @gold_number_sprite = Sprite.new
- @gold_number_sprite.bitmap = @gold_number_bitmap
- @gold_number_sprite.z = 5002
- @gold_number_sprite.x = 15 + HUD_POS[0] + GOLD_POS[0]
- @gold_number_sprite.y = - 5 + HUD_POS[1] + GOLD_POS[1]
- @gold_im_cw = @gold_number_image.width / 10
- @gold_im_ch = @gold_number_image.height
- @gold_number_text = @gold.abs.to_s.split(//)
- for r in 0..@gold_number_text.size - 1
- @gold_number_abs = @gold_number_text[r].to_i
- @gold_src_rect = Rect.new(@gold_im_cw * @gold_number_abs, 0, @gold_im_cw, @gold_im_ch)
- @gold_number_bitmap.blt(0 + ((@gold_im_cw - 10) * r), 2, @gold_number_image, @gold_src_rect)
- end
- end
-
- #--------------------------------------------------------------------------
- # * Dispose
- #--------------------------------------------------------------------------
- def dispose
- return if @actor == nil
- #Hp Number Dispose
- @hp_number_sprite.bitmap.dispose
- @hp_number_sprite.dispose
- @hp_number_bitmap.dispose
- #HP Meter Dispose
- @hp_sprite.bitmap.dispose
- @hp_sprite.dispose
- @hp_bitmap.dispose
- #SP Number Dispose
- @sp_number_sprite.bitmap.dispose
- @sp_number_sprite.dispose
- @sp_number_bitmap.dispose
- #SP Meter Dispose
- @sp_sprite.bitmap.dispose
- @sp_sprite.dispose
- @sp_bitmap.dispose
- #States Dispose
- @states.bitmap.dispose
- @states.dispose
- #Level Meter Dispose
- @level_sprite.bitmap.dispose
- @level_sprite.dispose
- @level_bitmap.dispose
- #Level Number Dispose
- @level_number_sprite.bitmap.dispose
- @level_number_sprite.dispose
- @level_number_bitmap.dispose
- #Layout Dispose
- @layout_sprite.bitmap.dispose
- @layout_sprite.dispose
- #Face Dispose
- @face_sprite.bitmap.dispose
- @face_sprite.dispose
- @face_bitmap.dispose
- #gold Number Dispose
- @gold_number_sprite.bitmap.dispose
- @gold_number_sprite.bitmap = nil
- @gold_number_sprite.dispose
- @gold_number_sprite = nil
- @gold_number_bitmap.dispose
- @gold_number_bitmap = nil
- #Layout Dispose
- @gold_layout_sprite.bitmap.dispose
- @gold_layout_sprite.bitmap = nil
- @gold_layout_sprite.dispose
- @gold_layout_sprite = nil
- @gold_layout_bitmap.dispose
- @gold_layout_bitmap = nil
- #Dispose Images
- @hp_number_image.dispose
- @face_image.dispose
- @hp_image.dispose
- @sp_number_image.dispose
- @sp_image.dispose
- @level_number_image.dispose
- @level_image.dispose
- @gold_layout_image.dispose
- @gold_number_image.dispose
- end
-
- #--------------------------------------------------------------------------
- # * Update Visible
- #--------------------------------------------------------------------------
- def update_visible
- if $game_switches[DISABLE_HUD_SWITCH] == true
- hud_visible = false
- else
- hud_visible = true
- end
- @hp_number_sprite.visible = hud_visible
- @hp_sprite.visible = hud_visible
- @sp_number_sprite.visible = hud_visible
- @sp_sprite.visible = hud_visible
- @states.visible = hud_visible
- @level_sprite.visible = hud_visible
- @level_number_sprite.visible = hud_visible
- @layout_sprite.visible = hud_visible
- @face_sprite.visible = hud_visible
- @gold_number_sprite.visible = hud_visible
- @gold_layout_sprite.visible = hud_visible
- end
-
- #--------------------------------------------------------------------------
- # * Updade
- #--------------------------------------------------------------------------
- def update
- return if @actor == nil
- update_visible
- hp_number_update if @hp_old != @actor.hp
- hp_number_refresh if @hp_refresh == true or @actor.hp == 0
- sp_number_update if @sp_old != @actor.sp
- sp_number_refresh if @sp_refresh == true
- level_update if @level != @actor.level
- level_up_effect if @level_number_sprite.zoom_x > 1.00
- exp_update if @exp != @actor.exp
- states_effect if @states.zoom_x > 1.00
- face_refresh if can_refresh_face?
- face_normal if $game_temp.hud_face_time2 == 1
- face_effect
- states_update
- hp_flow_update
- sp_flow_update
- gold_number_down if @gold > $game_party.gold
- gold_number_up if @gold < $game_party.gold
- gold_number_update if @gold_refresh == true
- fade_update if HUD_FADE == true
- end
-
- #--------------------------------------------------------------------------
- # fade_update
- #--------------------------------------------------------------------------
- def fade_update
- x = ($game_player.real_x - $game_map.display_x) / 4
- y = ($game_player.real_y - $game_map.display_y) / 4
- if x < @oc_range_x and x > HUD_POS[0] - 5 and
- y > HUD_POS[1] and y < @oc_range_y and @hp_number_sprite.opacity > 120
- @hp_number_sprite.opacity -= 10
- @hp_sprite.opacity -= 10
- @sp_number_sprite.opacity -= 10
- @sp_sprite.opacity -= 10
- @states.opacity -= 10
- @level_sprite.opacity -= 10
- @level_number_sprite.opacity -= 10
- @layout_sprite.opacity -= 10
- @face_sprite.opacity -= 10
- elsif @hp_number_sprite.opacity < 255
- @hp_number_sprite.opacity += 10
- @hp_sprite.opacity += 10
- @sp_number_sprite.opacity += 10
- @sp_sprite.opacity += 10
- @states.opacity += 10
- @level_sprite.opacity += 10
- @level_number_sprite.opacity += 10
- @layout_sprite.opacity += 10
- @face_sprite.opacity += 10
- end
- end
-
- #--------------------------------------------------------------------------
- # * face_normal
- #--------------------------------------------------------------------------
- def face_normal
- $game_temp.hud_face_refresh = false
- if @actor.hp < @actor.maxhp * @low_hp / 100
- $game_temp.hud_face_type = 4
- else
- $game_temp.hud_face_type = 0
- end
- $game_temp.hud_face_type_old = $game_temp.hud_face_type
- $game_temp.hud_face_time2 = 0
- @face_sprite.bitmap.clear
- @face_src_rect_back = Rect.new(@face_cw * $game_temp.hud_face_type, 0,@face_cw , @face_ch)
- @face_bitmap.blt(0,0, @face_image, @face_src_rect_back)
- @face_sprite.x = HUD_POS[0] + FACE_POS[0]
- end
-
- #--------------------------------------------------------------------------
- # * can_refresh_face?
- #--------------------------------------------------------------------------
- def can_refresh_face?
- if $game_temp.hud_face_time > 0
- $game_temp.hud_face_time -= 1
- $game_temp.hud_face_time2 = 30 if $game_temp.hud_face_time == 0
- else
- $game_temp.hud_face_time2 -= 1 if $game_temp.hud_face_time2 > 0
- end
- return false if $game_temp.hud_face_type_old == $game_temp.hud_face_type and
- $game_temp.hud_face_time > 1
- return true if $game_temp.hud_face_type_old != $game_temp.hud_face_type
- end
-
- #--------------------------------------------------------------------------
- # * Face Refresh
- #--------------------------------------------------------------------------
- def face_refresh
- $game_temp.hud_face_type_old = $game_temp.hud_face_type
- $game_temp.hud_face_time = 30
- $game_temp.hud_face_time2 = 0
- @face_sprite.bitmap.clear
- @face_src_rect_back = Rect.new(@face_cw * $game_temp.hud_face_type, 0,@face_cw , @face_ch)
- @face_bitmap.blt(0,0, @face_image, @face_src_rect_back)
- @face_sprite.x = HUD_POS[0] + FACE_POS[0]
- end
-
- #--------------------------------------------------------------------------
- # * Face Effect
- #--------------------------------------------------------------------------
- def face_effect
- if $game_temp.hud_face_type == 2
- @face_sprite.x = HUD_POS[0] + FACE_POS[0] + rand(10)
- if $game_temp.hud_face_time == 2
- if @actor.hp < @actor.maxhp * @low_hp / 100
- $game_temp.hud_face_type = 4
- else
- $game_temp.hud_face_type = 0
- end
- end
- end
- end
-
- #--------------------------------------------------------------------------
- # * States_Update
- #--------------------------------------------------------------------------
- def states_update
- if STATES_POS_CHARACTER == true
- @states.x = 5 -(13 * @states_x) + $game_player.screen_x
- @states.y = @states_y + $game_player.screen_y
- else
- @states.x = HUD_POS[0] + STATES_POS[0]
- @states.y = @states_y + HUD_POS[1] + STATES_POS[1]
- end
- if FLOAT_STATES == true
- if @states_f == false
- @states_y += 1
- @states_f = true if @states_y > 10
- else
- @states_y -= 1
- @states_f = false if @states_y < -10
- end
- end
- @states.opacity = 155 + rand(100)
- if @states_x != @actor.states.size
- @states_x = @actor.states.size
- @states.bitmap.clear
- @states_max = 0
- sta = []
- for i in @actor.states
- unless @states_max > 3
- sta.push($data_states[i].name)
- if icon_exist?(sta[@states_max])
- image = RPG::Cache.icon(sta[@states_max])
- else
- image = RPG::Cache.icon("")
- end
- cw = image.width
- ch = image.height
- @states.bitmap.blt(26 * @states_max, 0, image, Rect.new(0, 0, cw, ch))
- @states_max += 1
- end
- end
- sta = nil
- if image != nil
- image.dispose
- end
- @states.zoom_x = 2
- @states.zoom_y = 2
- end
- end
-
- #--------------------------------------------------------------------------
- # * States_Effect
- #--------------------------------------------------------------------------
- def states_effect
- @states.zoom_x -= 0.02
- @states.zoom_y -= 0.02
- if @states.zoom_x <= 1.00
- @states.zoom_x = 1.00
- @states.zoom_y = 1.00
- end
- end
-
- #--------------------------------------------------------------------------
- # * hp_number_update
- #--------------------------------------------------------------------------
- def hp_number_update
- @hp_refresh = true
- if @hp_old < @actor.hp
- @hp_ref = 5 * (@actor.hp - @hp_old) / 100
- @hp_ref = 1 if @hp_ref < 1
- @hp += @hp_ref
- if $game_temp.hud_face_type != 1
- $game_temp.hud_face_type = 1
- $game_temp.hud_face_refresh = true
- @face_sprite.x = HUD_POS[0] + FACE_POS[0]
- end
- if @hp >= @actor.hp
- @hp_old = @actor.hp
- @hp = @actor.hp
- @hp_ref = 0
- if @actor.hp < @actor.maxhp * @low_hp / 100 and
- $game_temp.hud_face_type != 4
- $game_temp.hud_face_type = 4
- elsif $game_temp.hud_face_type != 0
- $game_temp.hud_face_type = 0
- end
- end
-
- elsif @hp_old > @actor.hp
- @hp_refresh = true
- @hp_ref = 5 * (@hp_old - @actor.hp) / 100
- @hp_ref = 1 if @hp_ref < 1
- @hp -= @hp_ref
- if $game_temp.hud_face_type != 2
- $game_temp.hud_face_type = 2
- $game_temp.hud_face_refresh = true
- end
- if @hp <= @actor.hp
- @hp_old = @actor.hp
- @hp = @actor.hp
- @hp_ref = 0
- if $game_temp.hud_face_type != 0
- $game_temp.hud_face_time = 30
- end
- end
- end
- end
-
- #--------------------------------------------------------------------------
- # * hp_number_refresh
- #--------------------------------------------------------------------------
- def hp_number_refresh
- @hp_number_sprite.bitmap.clear
- @hp = 0 if @actor.hp == 0
- @hp_number_text = @hp.abs.to_s.split(//)
- lowhp2 = @actor.maxhp * @low_hp / 100
- if @actor.hp < lowhp2
- @health2 = @im_ch
- else
- @health2 = 0
- end
- @hp_health = @health2
- for r in 0..@hp_number_text.size - 1
- @hp_number_abs = @hp_number_text[r].to_i
- @hp_src_rect = Rect.new(@im_cw * @hp_number_abs, @hp_health, @im_cw, @im_ch)
- @hp_number_bitmap.blt(20 + ((@im_cw - 7) * r), 0, @hp_number_image, @hp_src_rect)
- end
- @hp_refresh = false if @hp == @actor.hp
- end
-
- #--------------------------------------------------------------------------
- # * Hp Flow Update
- #--------------------------------------------------------------------------
- def hp_flow_update
- @hp_sprite.bitmap.clear
- @hp_width = @hp_range * @actor.hp / @actor.maxhp
-
- #HP Damage---------------------------------
- valor = (@hp_width_old - @hp_width) * 3 / 100
- valor = 0.5 if valor < 1
- if @hp_width_old != @hp_width
- @hp_width_old -= valor if @hp_width_old > @hp_width
- if @hp_width_old < @hp_width
- @hp_width_old = @hp_width
- end
- @hp_src_rect_old = Rect.new(@hp_flow, @hp_height,@hp_width_old, @hp_height)
- @hp_bitmap.blt(0,0, @hp_image, @hp_src_rect_old)
- end
-
- #HP Real------------------------------------
- #@hp_src_rect = Rect.new(@hp_flow, 0,@hp_width, @hp_height)
- @hp_src_rect = Rect.new(@step * 100 , 0,@hp_width, @hp_height)
- @hp_bitmap.blt(0,0, @hp_image, @hp_src_rect)
- @step += 1 if Graphics.frame_count % 10 == 0 #%數後數值越小,速度越快
- @step = 0 if @step > 3
- # @hp_flow += 5
- # if @hp_flow >= @hp_image.width - @hp_range
- # @hp_flow = 0
- # end
- end
-
- #--------------------------------------------------------------------------
- # * Sp_number_update
- #--------------------------------------------------------------------------
- def sp_number_update
- @sp_refresh = true
- if @sp_old < @actor.sp
- @sp_refresh = true
- @sp_ref = 5 * (@actor.sp - @sp_old) / 100
- @sp_ref = 1 if @sp_ref < 1
- @sp += @sp_ref
- if $game_temp.hud_face_type != 1
- $game_temp.hud_face_type = 1
- $game_temp.hud_face_refresh = true
- @face_sprite.x = HUD_POS[0] + FACE_POS[0]
- end
- if @sp >= @actor.sp
- @sp_old = @actor.sp
- @sp = @actor.sp
- @sp_ref = 0
- if @actor.hp < @actor.maxhp * @low_hp / 100 and
- $game_temp.hud_face_type != 4
- $game_temp.hud_face_type = 4
- elsif $game_temp.hud_face_type != 0
- $game_temp.hud_face_type = 0
- end
- end
- elsif @sp_old >= @actor.sp
- @sp_ref = 5 * (@sp_old - @actor.sp) / 100
- @sp_ref = 1 if @sp_ref < 1
- @sp -= @sp_ref
- if $game_temp.hud_face_type != 3
- $game_temp.hud_face_type = 3 unless $game_player.action != nil
- end
- if @sp <= @actor.sp
- @sp_old = @actor.sp
- @sp = @actor.sp
- @sp_ref = 0
- if @actor.hp < @actor.maxhp * @low_hp / 100 and
- $game_temp.hud_face_type != 4
- # $game_temp.hud_face_type = 4
- elsif $game_temp.hud_face_type != 0
- $game_temp.hud_face_type = 0
- end
- end
- end
- end
-
- #--------------------------------------------------------------------------
- # * sp_number_refresh
- #--------------------------------------------------------------------------
- def sp_number_refresh
- @sp_number_sprite.bitmap.clear
- @s = @actor.sp * 100 / @actor.maxsp
- @sp_number_text = @sp.abs.to_s.split(//)
- for r in 0..@sp_number_text.size - 1
- @sp_number_abs = @sp_number_text[r].to_i
- if @actor.sp <= @actor.maxsp * @low_sp / 100
- @sp_src_rect = Rect.new(@sp_im_cw * @sp_number_abs, @sp_im_ch, @sp_im_cw, @sp_im_ch)
- else
- @sp_src_rect = Rect.new(@sp_im_cw * @sp_number_abs, 0, @sp_im_cw, @sp_im_ch)
- end
- @sp_number_bitmap.blt(20 + ((@sp_im_cw - 7) * r), 0, @sp_number_image, @sp_src_rect)
- end
- @sp_refresh = false if @sp == @actor.sp
- end
-
- #--------------------------------------------------------------------------
- # * Sp Flow Update
- #--------------------------------------------------------------------------
- def sp_flow_update
- @sp_sprite.bitmap.clear
- @sp_width = @sp_range * @actor.sp / @actor.maxsp
- #SP Damage---------------------------------
- if @sp_width_old != @sp_width
- valor = (@sp_width_old - @sp_width) * 3 / 100
- valor = 0.5 if valor < 1
- @sp_width_old -= valor if @sp_width_old > @sp_width
- if @sp_width_old < @sp_width
- @sp_width_old = @sp_width
- end
- @sp_src_rect_old = Rect.new(@sp_flow, @sp_height,@sp_width_old, @sp_height)
- @sp_bitmap.blt(0,0, @sp_image, @sp_src_rect_old)
- end
- #SP Real------------------------------------
- # @sp_src_rect = Rect.new(@sp_flow, 0,@sp_width, @sp_height)
- @sp_src_rect = Rect.new(@step * 100 , 0,@sp_width, @sp_height)
- @sp_bitmap.blt(0,0, @sp_image, @sp_src_rect)
-
- # @sp_flow += 5
- # if @sp_flow >= @sp_image.width - @sp_range
- # @sp_flow = 0
- # end
- end
-
- #--------------------------------------------------------------------------
- # * level_update
- #--------------------------------------------------------------------------
- def level_update
- @level_number_sprite.bitmap.clear
- @level_number_text = @actor.level.abs.to_s.split(//)
- for r in 0..@level_number_text.size - 1
- @level_number_abs = @level_number_text[r].to_i
- @level_src_rect = Rect.new(@level_im_cw * @level_number_abs, 0, @level_im_cw, @level_im_ch)
- @level_number_bitmap.blt(13 + ((@level_im_cw - 12) * r), 0, @level_number_image, @level_src_rect)
- end
- @level = @actor.level
- @level_number_sprite.zoom_x = 2
- @level_number_sprite.zoom_y = 2
- end
-
- #--------------------------------------------------------------------------
- # * level_update
- #--------------------------------------------------------------------------
- def level_up_effect
- @level_number_sprite.zoom_x -= 0.02
- @level_number_sprite.zoom_y -= 0.02
- if @level_number_sprite.zoom_x <= 1.00
- @level_number_sprite.zoom_x = 1.00
- @level_number_sprite.zoom_y = 1.00
- end
- end
-
- #--------------------------------------------------------------------------
- # * exp_update
- #--------------------------------------------------------------------------
- def exp_update
- @level_sprite.bitmap.clear
- rate = @actor.now_exp.to_f / @actor.next_exp
- rate = 1 if @actor.next_exp == 0
- @level_cw = @level_image.width * rate
- @level_cw = @level_image.width if @actor.level == 99
- @level_src_rect_back = Rect.new(0, 0,@level_cw, @level_image.height)
- @level_bitmap.blt(0,0, @level_image, @level_src_rect_back)
- @exp = @actor.exp
- end
-
- #--------------------------------------------------------------------------
- # * gold_number_up
- #--------------------------------------------------------------------------
- def gold_number_up
- @gold_refresh = true
- @gold_ref = 20 * (@gold - @gold_old) / 100
- @gold_ref = 1 if @gold_ref < 1
- @gold += @gold_ref
- if @gold >= $game_party.gold
- @gold_old = $game_party.gold
- @gold = $game_party.gold
- @gold_ref = 0
- end
- end
- #--------------------------------------------------------------------------
- # * gold_number_down
- #--------------------------------------------------------------------------
- def gold_number_down
- @gold_refresh = true
- @gold_ref = 10 * (@gold_old - @gold) / 100
- @gold_ref = 1 if @gold_ref < 1
- @gold -= @gold_ref
- if @gold <= $game_party.gold
- @gold_old = $game_party.gold
- @gold = $game_party.gold
- @gold_ref = 0
- end
- end
-
- #--------------------------------------------------------------------------
- # * gold_number_update
- #--------------------------------------------------------------------------
- def gold_number_update
- @gold_number_sprite.bitmap.clear
- @gold_number_text = @gold.abs.to_s.split(//)
- for r in 0..@gold_number_text.size - 1
- @gold_number_abs = @gold_number_text[r].to_i
- @gold_src_rect = Rect.new(@gold_im_cw * @gold_number_abs, 0, @gold_im_cw, @gold_im_ch)
- @gold_number_bitmap.blt(0 + ((@gold_im_cw - 10) * r), 2, @gold_number_image, @gold_src_rect)
- end
- @gold_refresh = false if @gold == $game_party.gold
- end
-
- end
- =begin
- #===============================================================================
- # ** Spriteset_Map
- #===============================================================================
- class Spriteset_Map
- #--------------------------------------------------------------------------
- # * initialize
- #--------------------------------------------------------------------------
- alias mog_achud_initialize initialize
- def initialize
- @acthud = Active_Hud.new
- mog_achud_initialize
- end
-
- #--------------------------------------------------------------------------
- # * Dispose
- #--------------------------------------------------------------------------
- alias mog_achud_dispose dispose
- def dispose
- mog_achud_dispose
- @acthud.dispose
- end
-
- #--------------------------------------------------------------------------
- # * Frame Update
- #--------------------------------------------------------------------------
- alias mog_achud_update update
- def update
- mog_achud_update
- @acthud.update
- end
- end
- =end
- #===============================================================================
- # ** Scene_Map
- #===============================================================================
- class Scene_Map
- #--------------------------------------------------------------------------
- # * main
- #--------------------------------------------------------------------------
- alias mog_achud_main main
- def main
- @acthud = Active_Hud.new
- mog_achud_main
- @acthud.dispose
- end
- #--------------------------------------------------------------------------
- # * Frame Update
- #--------------------------------------------------------------------------
- alias mog_achud_update update
- def update
- mog_achud_update
- @acthud.update
- end
- end
- $mog_rgss_active_hud = true
复制代码 timmyyayaya于2011-12-4 19:06补充以下内容:
好的 已经补上@@ |
|