Project1
标题:
关于敌人hp问题
[打印本页]
作者:
qq26524701
时间:
2013-5-23 20:01
标题:
关于敌人hp问题
想得到数据库里面敌人的hp数值显示在窗口中
$data_enemies[1].hp 不是代表数据库第一敌人的hp吗??
为什么会显示错误
作者:
Sion
时间:
2013-5-23 20:22
RPG::Enemy 里面没有定义这个函数
你应该按 F1 查看一下都有哪些属性、方法可以调用
作者:
qq26524701
时间:
2013-5-23 20:33
Sion 发表于 2013-5-23 20:22
RPG::Enemy 里面没有定义这个函数
你应该按 F1 查看一下都有哪些属性、方法可以调用 ...
f1是日文怎么办????
作者:
救世小树
时间:
2013-5-24 11:08
数据库敌人是只有hp上限而没有实际的hp的,只有真实的敌人才有hp,数据库那是敌人的“图纸”
要用 $game_troop.alive_members[index].hp
#encoding:utf-8
#==============================================================================
# ■ Window_BattleEnemy
#------------------------------------------------------------------------------
# 战斗画面中,选择“敌人目标”的窗口。
#==============================================================================
class Window_BattleEnemy < Window_Selectable
#--------------------------------------------------------------------------
# ● 初始化对象
# info_viewport : 信息显示用显示端口
#--------------------------------------------------------------------------
def initialize(info_viewport)
super(0, info_viewport.rect.y, window_width, fitting_height(5))
refresh
self.visible = false
@info_viewport = info_viewport
end
#--------------------------------------------------------------------------
# ● 获取窗口的宽度
#--------------------------------------------------------------------------
def window_width
Graphics.width - 128
end
#--------------------------------------------------------------------------
# ● 获取列数
#--------------------------------------------------------------------------
def col_max
return 1
end
#--------------------------------------------------------------------------
# ● 获取项目数
#--------------------------------------------------------------------------
def item_max
$game_troop.alive_members.size
end
#--------------------------------------------------------------------------
# ● 获取敌人实例
#--------------------------------------------------------------------------
def enemy
$game_troop.alive_members[@index]
end
#--------------------------------------------------------------------------
# ● 绘制项目
#--------------------------------------------------------------------------
def draw_item(index)
change_color(normal_color)
name = $game_troop.alive_members[index].name
draw_text(item_rect_for_text(index), name)
draw_enemy_icons(
$game_troop.alive_members[index],
item_rect(index).width - 350,item_rect(index).y)
draw_gauge(
item_rect(index).width - 250,
item_rect(index).y-8,
140,
$game_troop.alive_members[index].hp_rate,
Color.new(255,0,0), Color.new(0,255,0))
draw_gauge(
item_rect(index).width - 100,
item_rect(index).y-8,
80,
$game_troop.alive_members[index].mp_rate,
Color.new(1,1,205), Color.new(0,33,255))
draw_current_and_max_values(
item_rect(index).width - 250,
item_rect(index).y,140,
$game_troop.alive_members[index].hp,
$game_troop.alive_members[index].mhp,
hp_color($game_troop.alive_members[index]),
normal_color
)
end
def draw_enemy_icons(enemy, x, y, width = 96)
icons = (enemy.state_icons + enemy.buff_icons)[0, width / 24]
icons.each_with_index {|n, i| draw_icon(n, x + 24 * i, y) }
end
def draw_current_and_max_values(x, y, width, current, max, color1, color2)
change_color(color1)
xr = x + width
draw_text(xr - 132, y, 62, line_height, current, 2)
change_color(color2)
draw_text(xr - 72, y, 12, line_height, "/", 2)
draw_text(xr - 62, y, 62, line_height, max, 2)
end
#--------------------------------------------------------------------------
# ● 显示窗口
#--------------------------------------------------------------------------
def show
if @info_viewport
width_remain = Graphics.width - width
self.x = width_remain
@info_viewport.rect.width = width_remain
select(0)
end
super
end
#--------------------------------------------------------------------------
# ● 隐藏窗口
#--------------------------------------------------------------------------
def hide
@info_viewport.rect.width = Graphics.width if @info_viewport
super
end
end
复制代码
自己写的在选择敌人窗口显示敌人血蓝你可以参考下,血条蓝条颜色选不太来。
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1