#============================================================================== module PLAN_HPSP_DRAW FONT_NAME = ["宋体","黑体"] # フォント FONT_SIZE = 16 # 字体大小 FONT_BOLD = true # 太字 FONT_ITALIC = false #true # 斜体 DRAW_NAME = true # 名前の描画 DRAW_HP = true#false # HP の描画 DRAW_SP = true#false # SP の描画 DRAW_WIDTH = 80 * 2 + 20 # 描画幅 DRAW_HEIGHT = 3 * 32 # 描画高さ DRAW_SPACE = 0 # 行間 DRAW_Y = 24 # Y 座標修正値 end class Sprite_Battler < RPG::Sprite #-------------------------------------------------------------------------- # ● 对象初始化 #-------------------------------------------------------------------------- alias plan_enemy_hpsp_draw_initialize initialize def initialize(viewport, battler = nil) # 元のメソッドに戻す plan_enemy_hpsp_draw_initialize(viewport, battler) # エネミーの場合 if @battler.is_a?(Game_Enemy) width = PLAN_HPSP_DRAW::DRAW_WIDTH + 32 height = PLAN_HPSP_DRAW::DRAW_HEIGHT + 32 x = @battler.screen_x - width / 2 y = @battler.screen_y - height + 32 + PLAN_HPSP_DRAW::DRAW_Y #@enemy_hpsp_window = Window_Base.new(x, y, width, height) 原来这样 # 这样设置可以调整Z坐标了 ObjectSpace.each_object(Spriteset_Battle) {|obj| @enemy_hpsp_window = Window_Base.new(x, y, width, height,obj.instance_eval("@viewport1"))} @enemy_hpsp_window.contents = Bitmap.new(width - 32, height - 32) @enemy_hpsp_window.contents.font.name = PLAN_HPSP_DRAW::FONT_NAME @enemy_hpsp_window.contents.font.size = PLAN_HPSP_DRAW::FONT_SIZE @enemy_hpsp_window.contents.font.bold = PLAN_HPSP_DRAW::FONT_BOLD @enemy_hpsp_window.contents.font.italic = PLAN_HPSP_DRAW::FONT_ITALIC y = 0 @old_enemy_hpsp = [] one_line = ((PLAN_HPSP_DRAW::FONT_SIZE * 100 / 28) * 32) / 100 # 窗口名字的位置 if PLAN_HPSP_DRAW::DRAW_NAME @enemy_hpsp_window.draw_actor_name(@battler, -10, y, width - 32) y += one_line + PLAN_HPSP_DRAW::DRAW_SPACE @old_enemy_hpsp.push(@battler.name) end # 窗口HP的位置 if PLAN_HPSP_DRAW::DRAW_HP @enemy_hpsp_window.draw_actor_hp(@battler, 0, y, width - 32) y += one_line + PLAN_HPSP_DRAW::DRAW_SPACE @old_enemy_hpsp.push(@battler.hp) end # 窗口SP的位置 if PLAN_HPSP_DRAW::DRAW_SP @enemy_hpsp_window.draw_actor_sp(@battler, 0, y, width - 32) @old_enemy_hpsp.push(@battler.sp) end # 窗口透明度 @enemy_hpsp_window.opacity = 150 @enemy_hpsp_window.contents_opacity = 150 #@enemy_hpsp_window.z = -2 end end #-------------------------------------------------------------------------- # ● 解放 #-------------------------------------------------------------------------- alias plan_enemy_hpsp_draw_dispose dispose def dispose # エネミーの場合 if @battler.is_a?(Game_Enemy) @enemy_hpsp_window.dispose end # 元のメソッドに戻す plan_enemy_hpsp_draw_dispose end #-------------------------------------------------------------------------- # ● 框架更新 #-------------------------------------------------------------------------- alias plan_enemy_hpsp_draw_update update def update # 元のメソッドに戻す plan_enemy_hpsp_draw_update # エネミーの場合 if @battler.is_a?(Game_Enemy) @enemy_hpsp_window.visible = @battler_visible # 调整窗口坐标 width = PLAN_HPSP_DRAW::DRAW_WIDTH @enemy_hpsp_window.x = self.x - width / 2 - 18 @enemy_hpsp_window.y = self.y - 30 @enemy_hpsp_window.z = 0 @now_enemy_hpsp = [] if PLAN_HPSP_DRAW::DRAW_NAME @now_enemy_hpsp.push(@battler.name) end if PLAN_HPSP_DRAW::DRAW_HP @now_enemy_hpsp.push(@battler.hp) end if PLAN_HPSP_DRAW::DRAW_SP @now_enemy_hpsp.push(@battler.sp) end if @old_enemy_hpsp != @now_enemy_hpsp and $game_temp.enemy_hpsp_refresh @old_enemy_hpsp = @now_enemy_hpsp @enemy_hpsp_window.contents.clear y = 0 width = PLAN_HPSP_DRAW::DRAW_WIDTH + 32 one_line = ((PLAN_HPSP_DRAW::FONT_SIZE * 100 / 28) * 32) / 100 if PLAN_HPSP_DRAW::DRAW_NAME @enemy_hpsp_window.draw_actor_name(@battler, 0, y, width - 32) y += one_line + PLAN_HPSP_DRAW::DRAW_SPACE end if PLAN_HPSP_DRAW::DRAW_HP @enemy_hpsp_window.draw_actor_hp(@battler, 0, y, width - 32) y += one_line + PLAN_HPSP_DRAW::DRAW_SPACE end if PLAN_HPSP_DRAW::DRAW_SP @enemy_hpsp_window.draw_actor_sp(@battler, 0, y, width - 32) end Graphics.frame_reset end end end #-------------------------------------------------------------------------- # ● visible の設定 #-------------------------------------------------------------------------- if !method_defined?("plan_enemy_hpsp_draw_visible=") alias plan_enemy_hpsp_draw_visible= visible= end def visible=(bool) # 虚拟的情况 if @battler.is_a?(Game_Enemy) @enemy_hpsp_window.visible = bool end # 恢复原来的方法 self.plan_enemy_hpsp_draw_visible=(bool) end #-------------------------------------------------------------------------- # ● 设置不透明度 #-------------------------------------------------------------------------- if !method_defined?("plan_enemy_hpsp_draw_opacity=") alias plan_enemy_hpsp_draw_opacity= opacity= end def opacity=(n) # 恢复原来的方法 self.plan_enemy_hpsp_draw_opacity=(n) # 虚拟的情况 if @battler.is_a?(Game_Enemy) @enemy_hpsp_window.contents_opacity = n end end #-------------------------------------------------------------------------- # ● 伤害 #-------------------------------------------------------------------------- def damage(value, critical) super(value, critical) bitmap = @_damage_sprite.bitmap @_damage_sprite.dispose @_damage_sprite = ::Sprite.new(Viewport.new(0, 0, 640, 480)) @_damage_sprite.bitmap = bitmap @_damage_sprite.ox = 80 @_damage_sprite.oy = 20 @_damage_sprite.x = self.x @_damage_sprite.y = self.y - self.oy / 2 @_damage_sprite.viewport.z = self.viewport.z + 1 @_damage_sprite.z = 3000 @_damage_duration = 40 end #-------------------------------------------------------------------------- # ● 伤害解除 #-------------------------------------------------------------------------- def dispose_damage if @_damage_sprite != nil @_damage_sprite.viewport.dispose end super end end class Game_Temp #-------------------------------------------------------------------------- # ● 公开实例变量 #-------------------------------------------------------------------------- attr_accessor :enemy_hpsp_refresh #-------------------------------------------------------------------------- # ● 对象初始化 #-------------------------------------------------------------------------- alias plan_enemy_hpsp_draw_initialize initialize def initialize # 恢复原来的方法 plan_enemy_hpsp_draw_initialize @enemy_hpsp_refresh = false end end class Scene_Battle #-------------------------------------------------------------------------- # ● 预战斗阶段开始(用于艾涅米名字+字母) #-------------------------------------------------------------------------- alias plan_enemy_hpsp_draw_start_phase1 start_phase1 def start_phase1 $game_temp.enemy_hpsp_refresh = true # 恢复原来的方法 plan_enemy_hpsp_draw_start_phase1 end #-------------------------------------------------------------------------- # ● 开始方命令阶段(用于枚举名称+字母) #-------------------------------------------------------------------------- alias plan_enemy_hpsp_draw_start_phase2 start_phase2 def start_phase2 $game_temp.enemy_hpsp_refresh = false # 恢复原来的方法 plan_enemy_hpsp_draw_start_phase2 end #-------------------------------------------------------------------------- # ● 框架更新(主阶段步骤5:伤害表示) #-------------------------------------------------------------------------- alias plan_enemy_hpsp_draw_update_phase4_step5 update_phase4_step5 def update_phase4_step5 # 恢复原来的方法 plan_enemy_hpsp_draw_update_phase4_step5 $game_temp.enemy_hpsp_refresh = true end #-------------------------------------------------------------------------- # ● 框架更新(主阶段步骤6:刷新) #-------------------------------------------------------------------------- alias plan_enemy_hpsp_draw_update_phase4_step6 update_phase4_step6 def update_phase4_step6 # 恢复原来的方法 plan_enemy_hpsp_draw_update_phase4_step6 $game_temp.enemy_hpsp_refresh = false end end class Window_Base < Window #-------------------------------------------------------------------------- # ● 描绘名字 #-------------------------------------------------------------------------- def draw_actor_name(actor, x, y, width = 300) self.contents.font.color = Color.new(60, 255, 80) # 敌人名字的颜色 self.contents.font.bold = true # false self.contents.draw_text(x, y, 200, 32, actor.name,1) end end class Window_Base < Window def initialize(x, y, width, height, viewport = nil) super(viewport) @windowskin_name = $game_system.windowskin_name self.windowskin = RPG::Cache.windowskin(@windowskin_name) self.x = x self.y = y self.width = width self.height = height end end
黑夜守望者 发表于 2022-4-8 09:39
你想显示角色的血条魔条?简单说就是画2个矩形。
这里有教程:https://v.youku.com/v_show/id_XNDI5NjcwODI ...
黑米馒头 发表于 2022-4-8 19:41
我想做的是每个人都有独立窗口,里面有独立的血条魔法条~
黑夜守望者 发表于 2022-4-8 23:55
Window_Base里面追加2个定义:
然后在Window_BattleStatus的刷新函数里加上
黑米馒头 发表于 2022-4-9 08:54
这个方法我会了,就是不知道如何把每个人的血条都放到独立的框里面,你这样是全员的血条蓝条都在一个窗口 ...
黑夜守望者 发表于 2022-4-9 10:59
那就创建个窗口显示啊。和创建矩形的方法类似。
class Window_actorhpspbar < Window_Base #-------------------------------------------------------------------------- # ● 初始化对像 #-------------------------------------------------------------------------- def initialize(num) super(num*160,260,160,64) @num = num self.contents = Bitmap.new(120 , 30 ) refresh end def refresh self.contents.clear actor = $game_party.actors[@num] draw_actor_hp_bar(actor, 0, 0) draw_actor_sp_bar(actor, 0, 20) end end
@hpspbar_window1 = Window_actorhpspbar.new(0) if $game_party.actors[1] != nil @hpspbar_window2 = Window_actorhpspbar.new(1) end if $game_party.actors[2] != nil @hpspbar_window3 = Window_actorhpspbar.new(2) end if $game_party.actors[3] != nil @hpspbar_window4 = Window_actorhpspbar.new(3) end
@hpspbar_window1.dispose if @hpspbar_window2 != nil @hpspbar_window2.dispose end if @hpspbar_window3 != nil @hpspbar_window3.dispose end if @hpspbar_window4 != nil @hpspbar_window4.dispose end
@hpspbar_window1.refresh if @hpspbar_window2 != nil @hpspbar_window2.refresh end if @hpspbar_window3 != nil @hpspbar_window3.refresh end if @hpspbar_window4 != nil @hpspbar_window4.refresh end
黑夜守望者 发表于 2022-4-9 12:38
你可以新建一个专门显示血条魔条的窗口类:
class Window_actorhpspbar < Window_Base
#---------------- ...
黑米馒头 发表于 2022-4-9 14:45
就是这个效果,3Q
黑米馒头 发表于 2022-4-9 15:03
如果要每个血条都能调动位置呢,应该怎么加X Y Z值?
黑夜守望者 发表于 2022-4-9 15:12
super(num*160,260,160,64)
这句里面的前面两个参数num*160,260就是窗口出现的位置。
你可以在创建窗口 ...
1.71 MB, 下载次数: 6
黑米馒头 发表于 2022-4-9 19:21
大佬帮我看看,帮我修复一下,还是很刚开始一样,想弄成独立血条,不过好像失败了,战斗还很卡,弄了宠物 ...
黑夜守望者 发表于 2022-4-9 20:47
悲剧了,我居然打不开这个压缩包
黑夜守望者 发表于 2022-4-9 20:47
悲剧了,我居然打不开这个压缩包
黑米馒头 发表于 2022-4-9 21:20
可以下呀,要解压才行
1.72 MB, 下载次数: 0
黑夜守望者 发表于 2022-4-10 16:51
可以了,是我机子上的rar版本太低了。
黑夜守望者 发表于 2022-4-11 17:12
目前没发现卡……
还有我运行怎么还是640X480的窗口。
欢迎光临 Project1 (https://rpg.blue/) | Powered by Discuz! X3.1 |