赞 | 0 |
VIP | 0 |
好人卡 | 0 |
积分 | 1 |
经验 | 510 |
最后登录 | 2020-5-5 |
在线时间 | 0 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 55
- 在线时间
- 0 小时
- 注册时间
- 2007-8-19
- 帖子
- 35
|
正好最近做过类似的东西,顺便帮你改一下
class Window_HUD < Window_Base
def initialize
super(200,0,200,480)#########################窗口位置、大小
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.size = 20
refresh
end
def refresh
self.contents.clear
self.opacity = 0############################窗口透明度
actor = $game_actors[5]#######################角色ID
bitmap=Bitmap.new("Graphics/battlers/#{actor.battler_name}")
src_rect = Rect.new(0, 0, bitmap.width, bitmap.height)
self.contents.blt(0, 0, bitmap, src_rect)
x = 0
y = 108
draw_actor_name(actor,x,y)
self.contents.draw_text(x+100,y, 48, 32, "["+actor.class_name+"]")#职业位置
y += 20
draw_hp(actor,x,y+0)#描绘HP
draw_actor_parameter(actor,x,y + 20,3)#更改力量坐标
draw_actor_parameter(actor,x,y + 40,4)#更改灵巧坐标
$hudtemp = [actor.hp,actor.str,actor.dex,actor.class_id]
end
def draw_hp(actor, x, y)#重新定义描绘HP
# 描绘字符串 "HP"
self.contents.font.color = system_color
self.contents.draw_text(x, y, 32, 32, $data_system.words.hp)
# 计算描绘 MaxHP 所需的空间
if width - 32 >= 108
hp_x = x + width - 88
elsif width - 32 >= 48
hp_x = x + width - 28
end
# 描绘 HP
self.contents.font.color = actor.hp == 0 ? knockout_color :
actor.hp <= actor.maxhp / 4 ? crisis_color : normal_color
self.contents.draw_text(hp_x, y, 48, 32, actor.hp.to_s, 2)
end
end
class Scene_Map
SWITCH_ID = 150 ############################开关,打开时不显示窗口
alias raz_hud_main main
alias raz_hud_update update
def main
@hud_window = Window_HUD.new
@hud_window.visible = false#初始化时不可见
raz_hud_main
@hud_window.dispose
end
def update
@hud_window.visible = $game_switches[SWITCH_ID]#窗口的可见性和开关的真假值一致
actor = $game_actors[5]#######################角色ID
maptemp = [actor.hp,actor.str,actor.dex,actor.class_id]
for i in 4..5
if $hudtemp != maptemp then
@hud_window.refresh
@hud_window.update
end
end
raz_hud_update
end
end
按照你的要求改过了,不过感觉还有问题,如果还需要什么改进,给我留言吧 |
|