#-------------------------------------------------------------------------- # ● require Taroxd基础设置 # 给值槽增加动态的滚动效果 #-------------------------------------------------------------------------- class Taroxd::Transition # value: 当前值。changing: 当前是否正在变化 attr_reader :value, :changing # get_target.call 获取到变化的数据。可以使用 block 代替 get_target。 def initialize(duration, get_target = nil, &block) @duration = duration @get_target = get_target || block @value = @target = @get_target.call [url=home.php?mod=space&uid=188055]@d[/url] = 0 end # 更新值槽的值。如果值槽发生变化,返回 true。 def update @target = @get_target.call @changing = @value != @target update_transition if @changing @changing end private def update_transition @d = @duration if @d.zero? @d -= 1 @value = if @d.zero? @target else (@value * @d + @target).fdiv(@d + 1) end end end # include 之后,可用 @gauge_transitions[actor][:hp] 等 # 获取 Taroxd::Transition 的实例。 module Taroxd::RollGauge Transition = Taroxd::Transition def initialize(*) @gauge_transitions = make_gauge_transitions @gauge_roll_count = 0 super end def update super if (@gauge_roll_count += 1) >= gauge_roll_interval roll_all_gauge if update_gauge_transitions @gauge_roll_count = 0 end end def draw_actor_hp(actor, x, y, width = 124) hp = @gauge_transitions[actor][:hp].value rate = hp.fdiv(actor.mhp) draw_gauge(x, y, width, rate, hp_gauge_color1, hp_gauge_color2) change_color(system_color) draw_text(x, y, 30, line_height, Vocab::hp_a) draw_current_and_max_values(x, y, width, hp.to_i, actor.mhp, hp_color(actor), normal_color) end def draw_actor_mp(actor, x, y, width = 124) mp = @gauge_transitions[actor][:mp].value mmp = actor.mmp rate = mmp.zero? ? 0 : mp.fdiv(actor.mmp) draw_gauge(x, y, width, rate, mp_gauge_color1, mp_gauge_color2) change_color(system_color) draw_text(x, y, 30, line_height, Vocab::mp_a) draw_current_and_max_values(x, y, width, mp.to_i, actor.mmp, mp_color(actor), normal_color) end def draw_actor_tp(actor, x, y, width = 124) tp = @gauge_transitions[actor][:tp].value rate = tp.fdiv(actor.max_tp) draw_gauge(x, y, width, rate, tp_gauge_color1, tp_gauge_color2) change_color(system_color) draw_text(x, y, 30, line_height, Vocab::tp_a) change_color(tp_color(actor)) draw_text(x + width - 42, y, 42, line_height, tp.to_i, 2) end private # 获取 make_gauge_transitions 生成的对象 attr_reader :gauge_transitions # 值槽滚动所需的帧数 def gauge_roll_frame 30 end # 每隔多少帧更新一次值槽 def gauge_roll_interval 1 end # 生成值槽变化的数据。可在子类重定义。 # 默认的定义中,可以通过 gauge_transitions[actor][:hp] 等方式获取数据。 def make_gauge_transitions Hash.new { |hash, actor| hash[actor] = Hash.new do |h, k| h[k] = Transition.new(gauge_roll_times, actor.method(k)) end }.compare_by_identity end # 更新渐变的值。 # 返回真值则触发一次刷新。 # 每 gauge_roll_interval 帧调用一次。 def update_gauge_transitions need_roll = false gauge_transitions.each_value do |hash| hash.each_value do |t| need_roll = true if t.update end end need_roll end # 值槽滚动所需的次数。 def gauge_roll_times gauge_roll_frame / gauge_roll_interval end # 滚动所有值槽。可在子类重定义。 def roll_all_gauge refresh end end class Window_BattleStatus include Taroxd::RollGauge end class Window_MenuStatus < Window_Selectable include Taroxd::RollGauge def roll_all_gauge item_max.times do |i| actor = $game_party.members[i] rect = item_rect(i) rect.x += 108 rect.y += line_height / 2 contents.clear_rect(rect) draw_actor_simple_status(actor, rect.x, rect.y) end end end
#-------------------------------------------------------------------------- # ● require Taroxd基础设置,动态值槽 # 战斗中敌人显示血条 # 如不想显示,可在敌人处备注 <hide hp> # 可在敌人处备注 <hp width w>、<hp height h>、<hp dxy dx dy> 调整血槽。 # 其中 w 表示宽度、h 表示高度,dx、dy 表示坐标的偏移。 #-------------------------------------------------------------------------- Taroxd::EnemyHP = true class RPG::Enemy < RPG::BaseItem note_any :hp_dxy, [0, 0], /\s+(-?\d+)\s+(-?\d+)/, '[$1.to_i, $2.to_i]' note_i :hp_width, 80 note_i :hp_height, 6 note_bool :hide_hp? # 初始化并获取战斗图的尺寸 def init_width_height bitmap = Bitmap.new("Graphics/Battlers/#{@battler_name}") @width = bitmap.width [url=home.php?mod=space&uid=291977]@height[/url] = bitmap.height bitmap.dispose end def width return @width if @width init_width_height @width end def height return [url=home.php?mod=space&uid=291977]@height[/url] if @height init_width_height @height end end class Sprite_EnemyHP < Sprite include Taroxd::RollGauge include Taroxd::DisposeBitmap HP_COLOR1 = Color.new(223, 127, 63) HP_COLOR2 = Color.new(239, 191, 63) BACK_COLOR = Color.new(31, 31, 63) def initialize(viewport, enemy) @enemy = enemy super(viewport) data = enemy.enemy @width = data.hp_width @height = data.hp_height self.bitmap = Bitmap.new(@width, @height) dx, dy = enemy.enemy.hp_dxy self.ox = @width / 2 self.oy = @height self.x = enemy.screen_x + dx self.y = enemy.screen_y + dy self.z = enemy.screen_z + 10 refresh end def make_gauge_transitions Transition.new(gauge_roll_times) do @enemy.hp.fdiv(@enemy.mhp) end end def update_gauge_transitions gauge_transitions.update end def refresh bitmap.clear rate = gauge_transitions.value return if rate.zero? fill_w = (bitmap.width * rate).to_i bitmap.fill_rect(fill_w, 0, @width - fill_w, @height, BACK_COLOR) bitmap.gradient_fill_rect(0, 0, fill_w, @height, HP_COLOR1, HP_COLOR2) end end class Spriteset_Battle # 导入精灵组 def_after :create_enemies do @enemy_hp_sprites = $game_troop.members.map { |enemy| Sprite_EnemyHP.new(@viewport1, enemy) unless enemy.enemy.hide_hp? }.compact end def_after(:update_enemies) { @enemy_hp_sprites.each(&:update) } def_after(:dispose_enemies) { @enemy_hp_sprites.each(&:dispose) } end
求解.jpg (17.08 KB, 下载次数: 35)
01.jpg (12.95 KB, 下载次数: 35)
01首先 這是跟食人花戰鬥 下面沒丟備註出來的東西 (史萊姆不丟備柱也不會bug 但也不會有血條) ... ... ... ...
02.jpg (9.54 KB, 下载次数: 36)
02這是我不知道它的圖要幹嘛 隨便丟幾個出來試試的圖(這腳本需要的圖)
03.jpg (76.61 KB, 下载次数: 35)
03它只會顯示史萊姆b 然後 先不論血量條 數字條那裡怪怪的 我放數字的圖上去也怪怪的(不會用) ... ... .. ...
04.jpg (68.6 KB, 下载次数: 35)
04打死史萊姆A的變化
Battle_Boss_Meter.png (3.34 KB, 下载次数: 44)
Battle_Boss_Meter_Layout.png (3.54 KB, 下载次数: 47)
Battle_Boss_Number.png (10.67 KB, 下载次数: 37)
sam870716 发表于 2017-2-8 03:11
@300英雄
摁摁 首先有好幾個問題要問WWWW 不好意思
QQ截图20170210115910.png (39.21 KB, 下载次数: 33)
300英雄 发表于 2017-2-10 11:54
你的munbers是需要数组的,而你全黑,显示肯定也是全黑的,这是正常现象,按照楼主的提出的,血条不够长 ...
111.jpg (62.52 KB, 下载次数: 35)
欢迎光临 Project1 (https://rpg.blue/) | Powered by Discuz! X3.1 |