赞 | 5 |
VIP | 0 |
好人卡 | 2 |
积分 | 36 |
经验 | 24079 |
最后登录 | 2024-11-5 |
在线时间 | 1890 小时 |
Lv3.寻梦者
- 梦石
- 0
- 星屑
- 3591
- 在线时间
- 1890 小时
- 注册时间
- 2010-6-19
- 帖子
- 1211
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
本帖最后由 黑米馒头 于 2022-11-6 18:37 编辑
弄了显示敌方剩余战斗力的脚本,想在游戏结束的时候,让窗口隐藏了
首先生成窗口
@zanli = Window_BattleStatus.new
接着在Scene_Battle 1里
# 游戏结束的情况下
if $game_temp.gameover
# 隐藏敌方剩余战力窗口
@zanli.nrxc
# 切换到游戏结束画面
$scene = Scene_Gameover.new
return
end
但是会出现很奇怪的问题,有时候游戏结束窗口会隐藏,有时候又不会隐藏
战斗时显示
游戏结束的时候
未隐藏
隐藏
#------------------------------------------------------------------------------ # 显示敌方剩余战斗力 #============================================================================== #-------------------------------------------------------------------------- # □ 常数设置 #-------------------------------------------------------------------------- module ZENITH4 EG_WIDTH = 165+100 # 长度 EG_COLOR = Color.new(255,0,0,255) #(255, 180, 0, 255) # 战力颜色(黄色) EW_NAME = "敌方剩余生命" EW_COLOR = Color.new(255, 255, 255, 255) # 文字颜色 end #============================================================================== # ■ Window_BattleStatus #============================================================================== class Window_BattleStatus < Window_Base #-------------------------------------------------------------------------- # ● 对象初始化 #-------------------------------------------------------------------------- alias zenith4_initialize initialize def initialize @enemy_force = Sprite.new @enemy_force.bitmap = Bitmap.new(8 + ZENITH4::EG_WIDTH+100, 45) @enemy_force.x = 185 - (12 + ZENITH4::EG_WIDTH)+200 @enemy_force.y = 6#115 @enemy_force.z = 250 @nrbj = true zenith4_initialize end #-------------------------------------------------------------------------- # ● 解放 #-------------------------------------------------------------------------- alias zenith4_dispose dispose def dispose zenith4_dispose end #-------------------------------------------------------------------------- # ● 刷新 #-------------------------------------------------------------------------- alias zenith4_refresh refresh def refresh zenith4_refresh if @nrbj @enemy_force.visible = true @enemy_force.bitmap.clear x = 4 y = 4 width = ZENITH4::EG_WIDTH @enemy_force.bitmap.font.size = 18 # 描绘字体样式 @enemy_force.bitmap.font.name = (["黑体"]) @enemy_force.bitmap.font.color = Color.new(0, 0, 0, 255) # 描绘文字黑底 @enemy_force.bitmap.draw_text(x+1+3+24+50+100, y+1, width, 22, ZENITH4::EW_NAME) @enemy_force.bitmap.draw_text(x-1+3+24+50+100, y-1, width, 22, ZENITH4::EW_NAME) @enemy_force.bitmap.draw_text(x+1+3+24+50+100, y-1, width, 22, ZENITH4::EW_NAME) @enemy_force.bitmap.draw_text(x-1+3+24+50+100, y+1, width, 22, ZENITH4::EW_NAME) @enemy_force.bitmap.font.color = ZENITH4::EW_COLOR # 描绘文字 @enemy_force.bitmap.draw_text(x+3+24+50+100, y, width, 22, ZENITH4::EW_NAME) @item_max = $game_troop.enemies.size enemy_mh = 0 enemy_h = 0 for i in 0...@item_max enemy = $game_troop.enemies[i] next if enemy.hidden enemy_mh += enemy.maxhp enemy_h += enemy.hp end # 底部描绘 @enemy_force.bitmap.fill_rect(x-2+100, y+24, width+2,1, Color.new(152, 160, 88, 255)) @enemy_force.bitmap.fill_rect(x-1+100, y+26, width,3, Color.new(149,149,149,255)) @enemy_force.bitmap.fill_rect(x-2+100, y+30, width+2,1, Color.new(152, 160, 88, 255)) @enemy_force.bitmap.fill_rect(x-3+100, y+24, 1,7, Color.new(152, 160, 88, 255)) @enemy_force.bitmap.fill_rect(x+165+100+100, y+24, 1,7, Color.new(152, 160, 88, 255)) w = width * enemy_h / enemy_mh # 战力描绘 @enemy_force.bitmap.fill_rect(x-1+100, y+26, w,3, ZENITH4::EG_COLOR) end end def nrxc @nrbj = false @enemy_force.bitmap.dispose @enemy_force.dispose end end
#------------------------------------------------------------------------------
# 显示敌方剩余战斗力
#==============================================================================
#--------------------------------------------------------------------------
# □ 常数设置
#--------------------------------------------------------------------------
module ZENITH4
EG_WIDTH = 165+100 # 长度
EG_COLOR = Color.new(255,0,0,255) #(255, 180, 0, 255) # 战力颜色(黄色)
EW_NAME = "敌方剩余生命"
EW_COLOR = Color.new(255, 255, 255, 255) # 文字颜色
end
#==============================================================================
# ■ Window_BattleStatus
#==============================================================================
class Window_BattleStatus < Window_Base
#--------------------------------------------------------------------------
# ● 对象初始化
#--------------------------------------------------------------------------
alias zenith4_initialize initialize
def initialize
@enemy_force = Sprite.new
@enemy_force.bitmap = Bitmap.new(8 + ZENITH4::EG_WIDTH+100, 45)
@enemy_force.x = 185 - (12 + ZENITH4::EG_WIDTH)+200
@enemy_force.y = 6#115
@enemy_force.z = 250
@nrbj = true
zenith4_initialize
end
#--------------------------------------------------------------------------
# ● 解放
#--------------------------------------------------------------------------
alias zenith4_dispose dispose
def dispose
zenith4_dispose
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
alias zenith4_refresh refresh
def refresh
zenith4_refresh
if @nrbj
@enemy_force.visible = true
@enemy_force.bitmap.clear
x = 4
y = 4
width = ZENITH4::EG_WIDTH
@enemy_force.bitmap.font.size = 18
# 描绘字体样式
@enemy_force.bitmap.font.name = (["黑体"])
@enemy_force.bitmap.font.color = Color.new(0, 0, 0, 255)
# 描绘文字黑底
@enemy_force.bitmap.draw_text(x+1+3+24+50+100, y+1, width, 22, ZENITH4::EW_NAME)
@enemy_force.bitmap.draw_text(x-1+3+24+50+100, y-1, width, 22, ZENITH4::EW_NAME)
@enemy_force.bitmap.draw_text(x+1+3+24+50+100, y-1, width, 22, ZENITH4::EW_NAME)
@enemy_force.bitmap.draw_text(x-1+3+24+50+100, y+1, width, 22, ZENITH4::EW_NAME)
@enemy_force.bitmap.font.color = ZENITH4::EW_COLOR
# 描绘文字
@enemy_force.bitmap.draw_text(x+3+24+50+100, y, width, 22, ZENITH4::EW_NAME)
@item_max = $game_troop.enemies.size
enemy_mh = 0
enemy_h = 0
for i in 0...@item_max
enemy = $game_troop.enemies[i]
next if enemy.hidden
enemy_mh += enemy.maxhp
enemy_h += enemy.hp
end
# 底部描绘
@enemy_force.bitmap.fill_rect(x-2+100, y+24, width+2,1, Color.new(152, 160, 88, 255))
@enemy_force.bitmap.fill_rect(x-1+100, y+26, width,3, Color.new(149,149,149,255))
@enemy_force.bitmap.fill_rect(x-2+100, y+30, width+2,1, Color.new(152, 160, 88, 255))
@enemy_force.bitmap.fill_rect(x-3+100, y+24, 1,7, Color.new(152, 160, 88, 255))
@enemy_force.bitmap.fill_rect(x+165+100+100, y+24, 1,7, Color.new(152, 160, 88, 255))
w = width * enemy_h / enemy_mh
# 战力描绘
@enemy_force.bitmap.fill_rect(x-1+100, y+26, w,3, ZENITH4::EG_COLOR)
end
end
def nrxc
@nrbj = false
@enemy_force.bitmap.dispose
@enemy_force.dispose
end
end
|
|