赞 | 38 |
VIP | 2420 |
好人卡 | 100 |
积分 | 33 |
经验 | 75384 |
最后登录 | 2024-7-7 |
在线时间 | 3619 小时 |
Lv3.寻梦者 (暗夜天使) 名侦探小柯
- 梦石
- 0
- 星屑
- 3299
- 在线时间
- 3619 小时
- 注册时间
- 2006-9-6
- 帖子
- 37400
|
话说上次和你说的血条系统……
http://rpg.blue/upload_program/f ... 血条_90877848.rar
在加上配色脚本:
- #==============================================================================
- # ■ Sprite
- #==============================================================================
- class Sprite
- #--------------------------------------------------------------------------
- # ● 血条配色
- #--------------------------------------------------------------------------
- ALPHA = 192 # 不透明度
- FONT_COLOR = Color.new(64, 64, 240, ALPHA) # hp 数值
- B_COLOR = Color.new(255, 255, 255, ALPHA) # 血条外框
- BG_COLOR = Color.new( 0, 0, 0, ALPHA) # 血条底
- HP_COLOR_1 = Color.new(255, 128, 64, ALPHA) # 血条渐变色 1
- HP_COLOR_2 = Color.new(240, 192, 64, ALPHA) # 血条渐变色 2
- #--------------------------------------------------------------------------
- # ● 画血条
- #--------------------------------------------------------------------------
- def draw_character_hp(character, x, y, width)
- draw_character_hp_gauge(character, x, y, width)
- self.bitmap.font.color = FONT_COLOR
- self.bitmap.font.size = 12
- self.bitmap.draw_text(0,0,32,20,character.hp,2)
- end
- #--------------------------------------------------------------------------
- # ● 画血条的背景条
- #--------------------------------------------------------------------------
- def draw_character_hp_gauge(character, x, y, width)
- gw = width * character.hp / character.maxhp
- self.bitmap.fill_rect(x, y+16, width+2, 5, B_COLOR)
- self.bitmap.fill_rect(x+1, y+17, width, 3, BG_COLOR)
- self.bitmap.gradient_fill_rect(x+1, y+17, gw, 3, HP_COLOR_1, HP_COLOR_2)
- end
- end
- #==============================================================================
- # ■ Sprite_Character
- #==============================================================================
- class Sprite_Character < Sprite_Base
- #--------------------------------------------------------------------------
- # ● 定义实例变量
- #--------------------------------------------------------------------------
- attr_accessor :character
- #--------------------------------------------------------------------------
- # ● 释放
- #--------------------------------------------------------------------------
- def dispose
- dispose_balloon
- super
- if @hp_sprite != nil
- @hp_sprite.bitmap.dispose
- @hp_sprite.dispose
- @hp_sprite = nil
- end
- end
- #--------------------------------------------------------------------------
- # ● 更新画面
- #--------------------------------------------------------------------------
- alias old_update update
- def update
- old_update
- if @hp_sprite == nil
- unless @character.is_a?(Game_Vehicle) or @character.maxhp <= 0
- hp_sprite_set(@character)
- end
- end
- unless @character.is_a?(Game_Vehicle)
- hp_update if @character.update_hp
- end
- hp_follow
- end
- #--------------------------------------------------------------------------
- # ● 显示 hp
- #--------------------------------------------------------------------------
- def hp_sprite_set(character)
- @hp_sprite = Sprite.new
- @hp_sprite.bitmap = Bitmap.new(32, 24)
- @hp_sprite.draw_character_hp(character, 0, 0, width = 30)
- @hp_sprite.x = self.x - @hp_sprite.width/2
- @hp_sprite.y = self.y - self.height - 21
- @hp_sprite.z = self.z + 1
- end
- #--------------------------------------------------------------------------
- # ● 让 hp 跟随事件或角色
- #--------------------------------------------------------------------------
- def hp_follow
- return if @hp_sprite == nil
- return if @character.is_a?(Game_Vehicle)
- @hp_sprite.x = self.x - @hp_sprite.width/2
- @hp_sprite.y = self.y - self.height - 21
- @hp_sprite.z = self.z + 1
- end
- #--------------------------------------------------------------------------
- # ● 刷新 hp
- #--------------------------------------------------------------------------
- def hp_update
- return if @hp_sprite == nil
- return if @character.is_a?(Game_Vehicle)
- @character.update_hp = false
- @hp_sprite.bitmap.clear
- @hp_sprite.draw_character_hp(@character, 0, 0, width = 30)
- end
- end
- #==============================================================================
- # ■ Game_Event
- #==============================================================================
- class Game_Event < Game_Character
- #--------------------------------------------------------------------------
- # ● 定义实例变量
- #--------------------------------------------------------------------------
- attr_reader :hp
- attr_reader :maxhp
- attr_accessor :update_hp
- #--------------------------------------------------------------------------
- # ● 初始化对像
- # map_id : 地图 ID
- # event : 事件 (RPG::Event)
- #--------------------------------------------------------------------------
- alias ini initialize
- def initialize(map_id, event)
- @maxhp = @hp = 0
- @update_hp = false
- ini(map_id, event)
- end
- #--------------------------------------------------------------------------
- # ● 更改 hp
- # hp : 事件自身的hp
- #--------------------------------------------------------------------------
- def hp=(hp)
- @hp = hp
- @hp = 0 if @hp < 0
- @update_hp = true
- end
- #--------------------------------------------------------------------------
- # ● 初始化 maxhp
- # maxhp : 事件自身的最大 hp
- #--------------------------------------------------------------------------
- def maxhp=(maxhp)
- @maxhp = @hp = maxhp
- end
- end
- #==============================================================================
- # ■ Game_Player
- #==============================================================================
- class Game_Player < Game_Character
- #--------------------------------------------------------------------------
- # ● 定义实例变量
- #--------------------------------------------------------------------------
- attr_reader :hp
- attr_reader :maxhp
- attr_accessor :update_hp
- #--------------------------------------------------------------------------
- # ● 初始化对象
- #--------------------------------------------------------------------------
- alias ini initialize
- def initialize
- @maxhp = @hp = 0
- @update_hp = false
- ini
- end
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- def refresh
- if $game_party.members.size == 0
- @character_name = ""
- @character_index = 0
- else
- actor = $game_party.members[0] # 获得首名角色
- @character_name = actor.character_name
- @character_index = actor.character_index
- #获取角色 hp 和 maxhp
- if @hp != actor.hp or @maxhp != actor.maxhp
- @hp = actor.hp
- @maxhp = actor.maxhp
- @update_hp = true
- end
- end
- end
- end
- #==============================================================================
- # ■ Game_Interpreter
- #==============================================================================
- class Game_Interpreter
- #--------------------------------------------------------------------------
- # ● 设置正在启动的事件
- #--------------------------------------------------------------------------
- alias old_setup_starting_event setup_starting_event
- def setup_starting_event
- $game_player.refresh
- old_setup_starting_event
- end
- end
复制代码 |
|