Project1
标题:
如何让下面的脚本变成窗口?
[打印本页]
作者:
876加几
时间:
2013-10-20 19:00
标题:
如何让下面的脚本变成窗口?
我打印了一下,本身应该是Window的脚本结果不是true,而是false。
#==============================================================================
# ■ Window_ActorMessage
#------------------------------------------------------------------------------
# 显示角色血糟的窗口。
#==============================================================================
class Window_ActorMessage < Window_Base
#--------------------------------------------------------------------------
# ● 初始化窗口
#--------------------------------------------------------------------------
def initialize
super(0, 480 - 64, 640, 64)
self.contents = Bitmap.new(width - 32, height - 32)
self.opacity = 0
refresh
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
self.contents.clear
for i in 0...$game_party.actors.size
x = 160 * i
y = 0
actor = $game_party.actors[i]
draw_actor_head(actor, x, y)
carol3_draw_hp_bar(actor, x + 64, y + 1)
carol3_draw_sp_bar(actor, x + 64, y + 16)
carol3_draw_cp_bar(actor, x + 64, y + 32)
end
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
super
refresh
end
end
复制代码
方法:
#--------------------------------------------------------------------------
# ● 头像的描绘
# actor : 角色
# x : 描画目标 X 坐标
# y : 描画目标 Y 坐标
#--------------------------------------------------------------------------
def draw_actor_head(actor, x, y)
bitmap = RPG::Cache.picture(actor.character_name + "_h")
hea_rect = Rect.new(0, 0, bitmap.width, bitmap.height)
self.contents.blt(x, y, bitmap, hea_rect)
end
#---------------------------------------------------------------------------
# 定义新方法名,就相当于Window_Base的draw_actor_hp
# 带有四个参数,角色,你给谁描绘血条呢?给这个角色
# 参数描绘,相对的X,Y坐标,以及血条的宽度
# 方法名完全可以改为draw_actor_hp,在window中用
#---------------------------------------------------------------------------
def carol3_draw_hp_bar(actor, x, y, width = 78)
# 自身文字颜色为系统文字色
self.contents.fill_rect(x-1, y-1, width + 2,10, Color.new(0, 0, 0, 255))
# 计算红条宽度,很简单。宽度 = 角色当前HP / 最大HP × 宽度
w = width * actor.hp / actor.maxhp
# 填充矩形,要不颜色太单调,也不好看,下面四行不是重点
self.contents.fill_rect(x, y, w,8, Color.new(255, 0, 0, 255))
end
# 下方的基本一样,就不多废话了,只说不一样的地方。
def carol3_draw_sp_bar(actor, x, y, width = 78)
self.contents.fill_rect(x-1, y-1, width + 2,10, Color.new(0, 0, 0, 255))
w = width * actor.sp / actor.maxsp
#下方就不多说了。
self.contents.fill_rect(x, y, w,8, Color.new(0, 0, 255, 255))
end
def carol3_draw_cp_bar(actor, x, y, width = 58)
if actor.mor == 100
self.contents.fill_rect(x-2, y-2, width + 4,7, Color.new(0, 255, 0, 170))
end
self.contents.fill_rect(x-1, y-1, width + 2,5, Color.new(0, 0, 0, 255))
w = width * actor.mor / 100
self.contents.fill_rect(x, y, w,3, Color.new(0, 255, 0, 255))
end
复制代码
打印方法:
@squarebattleactormessage_window = Window_ActorMessage.new
p @squarebattleactormessage_window.is_a?(Window)
复制代码
应该为true,结果为false,这是怎么回事?
作者:
英顺的马甲
时间:
2013-10-20 21:13
无此问题,一切正常
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1