Project1
标题: 如何判断角色存在? [打印本页]
作者: zhangfuzhou 时间: 2013-10-13 15:12
标题: 如何判断角色存在?
#----------------------------------------------------------------------------
# * 更新内容
#----------------------------------------------------------------------------
def refresh
self.contents.clear
self.contents.font.size = 22
self.contents.font.bold = true
draw_actor_name($game_party.members[0], 0, 0)
self.contents.font.size = 18
self.contents.font.color = Color.new(176, 224, 230)
self.contents.draw_text(60, 350, self.contents.width - 40, 24, $game_party.members[1].level)
self.contents.draw_text(143, 350, self.contents.width - 40, 24, $game_party.members[2].level)
self.contents.draw_text(226, 350, self.contents.width - 40, 24, $game_party.members[3].level)
self.contents.font.color = Color.new(51, 161, 201)
self.contents.draw_text(80, 0, 42, 24, "Lv.")
self.contents.font.color = text_color(0)
self.contents.draw_text(110, 0, self.contents.width - 40, 24, $game_party.members[0].level)
draw_actor_icons($game_party.members[0], 0, 86,264)
draw_actor_icons($game_party.members[1], 0, 328,72)
draw_actor_icons($game_party.members[2], 83, 328,72)
draw_actor_icons($game_party.members[3], 166, 328,72)
draw_actor_hp($game_party.members[0], 0, 20, self.contents.width - 110)
draw_actor_mp($game_party.members[0], 0, 40, self.contents.width - 110)
draw_actor_exp($game_party.members[0], 0, 60, self.contents.width - 110)
self.contents.font.size = 14
draw_actor_name($game_party.members[1], 0, 350)
draw_actor_hp($game_party.members[1], 0, 363, self.contents.width - 167)
draw_actor_mp($game_party.members[1], 0, 378, self.contents.width - 167)
draw_actor_name($game_party.members[2], 83, 350)
draw_actor_hp($game_party.members[2], 83, 363, self.contents.width - 167)
draw_actor_mp($game_party.members[2], 83, 378, self.contents.width - 167)
draw_actor_name($game_party.members[3], 166, 350)
draw_actor_hp($game_party.members[3], 166, 363, self.contents.width - 167)
draw_actor_mp($game_party.members[3], 166, 378, self.contents.width - 167)
self.contents.font.bold = false
end
#----------------------------------------------------------------------------
# * 更新内容
#----------------------------------------------------------------------------
def refresh
self.contents.clear
self.contents.font.size = 22
self.contents.font.bold = true
draw_actor_name($game_party.members[0], 0, 0)
self.contents.font.size = 18
self.contents.font.color = Color.new(176, 224, 230)
self.contents.draw_text(60, 350, self.contents.width - 40, 24, $game_party.members[1].level)
self.contents.draw_text(143, 350, self.contents.width - 40, 24, $game_party.members[2].level)
self.contents.draw_text(226, 350, self.contents.width - 40, 24, $game_party.members[3].level)
self.contents.font.color = Color.new(51, 161, 201)
self.contents.draw_text(80, 0, 42, 24, "Lv.")
self.contents.font.color = text_color(0)
self.contents.draw_text(110, 0, self.contents.width - 40, 24, $game_party.members[0].level)
draw_actor_icons($game_party.members[0], 0, 86,264)
draw_actor_icons($game_party.members[1], 0, 328,72)
draw_actor_icons($game_party.members[2], 83, 328,72)
draw_actor_icons($game_party.members[3], 166, 328,72)
draw_actor_hp($game_party.members[0], 0, 20, self.contents.width - 110)
draw_actor_mp($game_party.members[0], 0, 40, self.contents.width - 110)
draw_actor_exp($game_party.members[0], 0, 60, self.contents.width - 110)
self.contents.font.size = 14
draw_actor_name($game_party.members[1], 0, 350)
draw_actor_hp($game_party.members[1], 0, 363, self.contents.width - 167)
draw_actor_mp($game_party.members[1], 0, 378, self.contents.width - 167)
draw_actor_name($game_party.members[2], 83, 350)
draw_actor_hp($game_party.members[2], 83, 363, self.contents.width - 167)
draw_actor_mp($game_party.members[2], 83, 378, self.contents.width - 167)
draw_actor_name($game_party.members[3], 166, 350)
draw_actor_hp($game_party.members[3], 166, 363, self.contents.width - 167)
draw_actor_mp($game_party.members[3], 166, 378, self.contents.width - 167)
self.contents.font.bold = false
end
这段脚本在一个窗口中显示4个角色的状态,初始角色是4个的时候执行正常,初始角色小于4个,就出问题了。请问如何修改,是判断初始角色是否存在还是有其他办法。
下面是窗口的刷新判断
#----------------------------------------------------------------------------
# * 刷新画面
#----------------------------------------------------------------------------
def update
super
refresh if $refresh
$refresh = false
if $game_player.screen_x >= 0 and $game_player.screen_x <= self.width and
$game_player.screen_y >= 0 and $game_player.screen_y <= self.height
self.contents_opacity = 60
else self.contents_opacity = 255
end
end
#----------------------------------------------------------------------------
# * 刷新画面
#----------------------------------------------------------------------------
def update
super
refresh if $refresh
$refresh = false
if $game_player.screen_x >= 0 and $game_player.screen_x <= self.width and
$game_player.screen_y >= 0 and $game_player.screen_y <= self.height
self.contents_opacity = 60
else self.contents_opacity = 255
end
end
以及刷新处理
class Game_Actor < Game_Battler
#----------------------------------------------------------------------------
# * 重命名方法
#----------------------------------------------------------------------------
alias ms_refresh refresh
alias ms_tp tp=
alias ms_add_state add_state
#--------------------------------------------------------------------------
# * 刷新
#--------------------------------------------------------------------------
def refresh
ms_refresh
$refresh = true
end
#----------------------------------------------------------------------------
# * 更改 TP
#----------------------------------------------------------------------------
def tp=(tp)
ms_tp(tp)
$refresh = true
end
#----------------------------------------------------------------------------
# * 附加状态
#----------------------------------------------------------------------------
def add_state(state_id)
ms_add_state(state_id)
$refresh = true
end
end
class Game_Party
#----------------------------------------------------------------------------
# * 重命名方法
#----------------------------------------------------------------------------
alias ms_swap_order swap_order
#----------------------------------------------------------------------------
# * 交换顺序
#----------------------------------------------------------------------------
def swap_order(index1, index2)
ms_swap_order(index1, index2)
$refresh = true
end
end
class Game_Actor < Game_Battler
#----------------------------------------------------------------------------
# * 重命名方法
#----------------------------------------------------------------------------
alias ms_refresh refresh
alias ms_tp tp=
alias ms_add_state add_state
#--------------------------------------------------------------------------
# * 刷新
#--------------------------------------------------------------------------
def refresh
ms_refresh
$refresh = true
end
#----------------------------------------------------------------------------
# * 更改 TP
#----------------------------------------------------------------------------
def tp=(tp)
ms_tp(tp)
$refresh = true
end
#----------------------------------------------------------------------------
# * 附加状态
#----------------------------------------------------------------------------
def add_state(state_id)
ms_add_state(state_id)
$refresh = true
end
end
class Game_Party
#----------------------------------------------------------------------------
# * 重命名方法
#----------------------------------------------------------------------------
alias ms_swap_order swap_order
#----------------------------------------------------------------------------
# * 交换顺序
#----------------------------------------------------------------------------
def swap_order(index1, index2)
ms_swap_order(index1, index2)
$refresh = true
end
end
求高手帮忙修改脚本啊,拜谢!!!
作者: 喵呜喵5 时间: 2013-10-13 15:33
- #----------------------------------------------------------------------------
- # * 更新内容
- #----------------------------------------------------------------------------
- def refresh
-
- self.contents.clear
- self.contents.font.size = 22
- self.contents.font.bold = true
-
- #绘制左上角的内容
- draw_actor_name($game_party.members[0], 0, 0)
- self.contents.draw_text(110, 0, self.contents.width - 40, 24, $game_party.members[0].level)
- self.contents.draw_text(80, 0, 42, 24, "Lv.")
- draw_actor_icons($game_party.members[0], 0, 86,264)
- draw_actor_hp($game_party.members[0], 0, 20, self.contents.width - 110)
- draw_actor_mp($game_party.members[0], 0, 40, self.contents.width - 110)
- draw_actor_exp($game_party.members[0], 0, 60, self.contents.width - 110)
- #绘制左下角的内容
- ($game_party.members.size - 1) times do |i|
- self.contents.draw_text(60+83*i, 350, self.contents.width - 40, 24, $game_party.members[i+1].level)
- draw_actor_icons($game_party.members[i+1], 83*i, 328,72)
- draw_actor_name($game_party.members[i+1], 83*i, 350)
- draw_actor_hp($game_party.members[i+1], 83*i, 363, self.contents.width - 167)
- draw_actor_mp($game_party.members[i+1], 83*i, 378, self.contents.width - 167)
- end
-
- end
复制代码 第一段代码换成这种感觉?(字体大小修改、颜色修改什么的都删掉了,可行的话之后你自己补回去吧……)
作者: zhangfuzhou 时间: 2013-10-13 15:42
我是个整体的窗口,就一个,在左侧- class Window_MapStatus < Window_Base
- #----------------------------------------------------------------------------
- # * 初始化
- #----------------------------------------------------------------------------
- def initialize
- super(0, 0, 271, 426)
- self.opacity = 255
- refresh
- end
复制代码 你这段脚本提示- ($game_party.members.size - 1) times do |i|
复制代码 出错,我把整个脚本给你看吧- #==============================================================================
- # ** Window_MapStatus
- #==============================================================================
- class Window_MapStatus < Window_Base
- #----------------------------------------------------------------------------
- # * 初始化
- #----------------------------------------------------------------------------
- def initialize
- super(0, 0, 271, 426)
- self.opacity = 0
- refresh
- end
- #----------------------------------------------------------------------------
- # * 刷新画面
- #----------------------------------------------------------------------------
- def update
- super
- refresh if $refresh
- $refresh = false
- if $game_player.screen_x >= 0 and $game_player.screen_x <= self.width and
- $game_player.screen_y >= 0 and $game_player.screen_y <= self.height
- self.contents_opacity = 60
- else self.contents_opacity = 255
- end
- end
- #----------------------------------------------------------------------------
- # * 更新内容
- #----------------------------------------------------------------------------
- def refresh
- self.contents.clear
- self.contents.font.size = 22
- self.contents.font.bold = true
- draw_actor_name($game_party.members[0], 0, 0)
- self.contents.font.size = 18
- self.contents.font.color = Color.new(64, 224, 208)
- self.contents.draw_text(60, 350, self.contents.width - 40, 24, $game_party.members[1].level)
- self.contents.draw_text(143, 350, self.contents.width - 40, 24, $game_party.members[2].level)
- self.contents.draw_text(226, 350, self.contents.width - 40, 24, $game_party.members[3].level)
- self.contents.font.color = Color.new(51, 161, 201)
- self.contents.draw_text(80, 0, 42, 24, "Lv.")
- self.contents.font.color = text_color(0)
- self.contents.draw_text(110, 0, self.contents.width - 40, 24, $game_party.members[0].level)
- draw_actor_icons($game_party.members[0], 0, 86,264)
- draw_actor_icons($game_party.members[1], 0, 328,72)
- draw_actor_icons($game_party.members[2], 83, 328,72)
- draw_actor_icons($game_party.members[3], 166, 328,72)
- draw_actor_hp($game_party.members[0], 0, 20, self.contents.width - 110)
- draw_actor_mp($game_party.members[0], 0, 40, self.contents.width - 110)
- draw_actor_exp($game_party.members[0], 0, 60, self.contents.width - 110)
- self.contents.font.size = 14
- draw_actor_name($game_party.members[1], 0, 350)
- draw_actor_hp($game_party.members[1], 0, 363, self.contents.width - 167)
- draw_actor_mp($game_party.members[1], 0, 378, self.contents.width - 167)
- draw_actor_name($game_party.members[2], 83, 350)
- draw_actor_hp($game_party.members[2], 83, 363, self.contents.width - 167)
- draw_actor_mp($game_party.members[2], 83, 378, self.contents.width - 167)
- draw_actor_name($game_party.members[3], 166, 350)
- draw_actor_hp($game_party.members[3], 166, 363, self.contents.width - 167)
- draw_actor_mp($game_party.members[3], 166, 378, self.contents.width - 167)
- self.contents.font.bold = false
- end
- #----------------------------------------------------------------------------
- # * 描绘EXP槽
- #----------------------------------------------------------------------------
- def draw_actor_exp(actor, x, y, width=124)
- rate = actor.exp.to_f / actor.next_level_exp.to_f
- draw_gauge(x, y, width, rate, Color.new(0, 255, 0), Color.new(100, 255, 100))
- self.contents.font.color = text_color(16)
- self.contents.draw_text(x, y, 56, 24, "EXP")
- self.contents.font.color = Color.new(255, 255, 255)
- en = "#{actor.exp}/#{actor.next_level_exp}"
- self.contents.draw_text(x, y, width, 24, en, 2)
- end
- #----------------------------------------------------------------------------
- # * 描绘值槽
- #----------------------------------------------------------------------------
- def draw_gauge(x, y, width, rate, color1, color2)
- fill_w = (width * rate).to_i
- self.contents.gradient_fill_rect(x, y+12, fill_w, 6, color1, color2, true)
- self.contents.gradient_fill_rect(x, y+18, fill_w, 6, color2, color1, true)
- self.contents.fill_rect(x, y+12, width, 2, Color.new(94, 38, 18))
- self.contents.fill_rect(x, y+22, width, 2, Color.new(94, 38, 18))
- self.contents.fill_rect(x, y+14, 2, 8, Color.new(94, 38, 18))
- self.contents.fill_rect(x+width-2, y+14, 2, 8, Color.new(94, 38, 18))
- end
- #----------------------------------------------------------------------------
- # * 描绘名称
- #----------------------------------------------------------------------------
- def draw_actor_name(actor, x, y, width = 112)
- color = Color.new(252, 230, 201)
- color = crisis_color if actor.hp < actor.mhp /
- color = knockout_color if actor.hp == 0
- change_color(color)
- draw_text(x, y, width, line_height, actor.name)
- end
- end
复制代码
作者: zhangfuzhou 时间: 2013-10-13 15:44
喵呜喵5 发表于 2013-10-13 15:33
第一段代码换成这种感觉?(字体大小修改、颜色修改什么的都删掉了,可行的话之后你自己补回去吧……) ...
请看上一楼,忘点回复了,回复成自己了
作者: 喵呜喵5 时间: 2013-10-13 15:49
本帖最后由 喵呜喵5 于 2013-10-13 15:51 编辑
zhangfuzhou 发表于 2013-10-13 15:44
请看上一楼,忘点回复了,回复成自己了
出错那一句改成- ($game_party.members.size - 1).times do |i|
复制代码 刚才漏打了一个点……
作者: zhangfuzhou 时间: 2013-10-13 15:56
喵呜喵5 发表于 2013-10-13 15:49
出错那一句改成刚才漏打了一个点……
十分感谢,已成功
欢迎光临 Project1 (https://rpg.blue/) |
Powered by Discuz! X3.1 |