Project1
标题:
打开17号开关显示HP条脚本,这个脚本开关设置为何无效?
[打印本页]
作者:
天使喝可乐
时间:
2011-7-6 09:40
标题:
打开17号开关显示HP条脚本,这个脚本开关设置为何无效?
这是个地图上显示HP条脚本,其中第一段是打开17号开关才显示HP条 不打开不显示。
但是现在是否打开17号开关,HP条都显示……也就是开关设置无效了
怎么试都不行..在默认工程中试验也是如此,所以应该不是脚本冲突的问题,求解,谢谢各位~
#-----------------------------------------------------------------
class Scene_Map
#-----------------------------------------------------------------
ID = 17
alias sk_bar_main main
def main
@bars = Window_Sk_Bars.new
sk_bar_main
@bars.dispose if @bars != nil
end
#-----------------------------------------------------------------
alias sk_bar_update update
def update
@bars.update
sk_bar_update
@bars.visible = $game_variables[ID]
end
#-----------------------------------------------------------------
end
#-----------------------------------------------------------------
class Window_Base < Window
#-----------------------------------------------------------------
def sk_initialize(font=0,size=22)
font = "Tahoma" if font == 0
self.contents = Bitmap.new(self.width-32,self.height-32)
self.contents.font.name = font
self.contents.font.size = size
end
#-----------------------------------------------------------------
def draw_text_outline(x,y,w,h,str,c=normal_color,a=0)
self.contents.font.color = Color.new(0,0,0,255)
self.contents.draw_text(x-1,y,w,h,str,a)
self.contents.draw_text(x+1,y,w,h,str,a)
self.contents.draw_text(x,y+1,w,h,str,a)
self.contents.draw_text(x,y-1,w,h,str,a)
self.contents.font.color = c
self.contents.draw_text(x,y,w,h,str,a)
end
#-----------------------------------------------------------------
end
#-----------------------------------------------------------------
class Window_Sk_Bars < Window_Base
#-----------------------------------------------------------------
def initialize
super(444,-8,206,96)
sk_initialize("Arial")
self.opacity = 0
end
#-----------------------------------------------------------------
def update
self.contents.clear
actor = $game_party.actors[0]
return if actor.nil?
draw_text_outline(0,-4,64,26,"HP")
draw_actor_hp(actor,30,0)
end
#-----------------------------------------------------------------
def draw_actor_hp(actor,x,y)
width = 128
y += 4
white = Color.new(255,255,255,255)
black = Color.new(0,0,0,255)
w = width * actor.hp / actor.maxhp
# White border
self.contents.fill_rect(x+1, y-1, width-2, 1, white)
self.contents.fill_rect(x, y, width, 1, white)
self.contents.fill_rect(x-1, y+1, width+2, 9, white)
self.contents.fill_rect(x, y+10, width, 1, white)
self.contents.fill_rect(x+1, y+11, width-2, 1, white)
# Black back
self.contents.fill_rect(x+2, y, width-4, 1, black)
self.contents.fill_rect(x+1, y+1, width-2, 1, black)
self.contents.fill_rect(x, y+2, width, 7, black)
self.contents.fill_rect(x+1, y+9, width-2, 1, black)
self.contents.fill_rect(x+2, y+10, width-4, 1, black)
# Generating the color
val = 255 * ((actor.hp*100)/actor.maxhp)
green = 255 - val/100
color = Color.new(224,green,0,255)
w_color = Color.new(255,green+32,96,255)
if green > 64 then green -= 32
elsif green > 128 then green -= 64 end
b_color = Color.new(172,green,0,255)
# Making the bar
self.contents.fill_rect(x+2, y, w-4, 1, w_color)
self.contents.fill_rect(x+1, y+1, w-2, 1, w_color)
self.contents.fill_rect(x, y+2, w, 7, color)
self.contents.fill_rect(x+1, y+9, w-2, 1, color)
self.contents.fill_rect(x+2, y+10, w-4, 1, b_color)
end
#-----------------------------------------------------------------
end
#-----------------------------------------------------------------
复制代码
作者:
镜花水月
时间:
2011-7-6 12:19
在16行修改为if $game_switches[ID]=true.
@bars.visible=true,
不行的话54
作者:
Wind2010
时间:
2011-7-6 12:20
把15和16行对调试试
作者:
fux2
时间:
2011-7-6 13:06
$game_variables是变量不是开关
16行改成@bars.visible = $game_switches[ID]
作者:
天使喝可乐
时间:
2011-7-6 13:35
为什么不能认可答案了= =囧
作者:
忧雪の伤
时间:
2011-7-6 19:13
#-----------------------------------------------------------------
class Scene_Map
#-----------------------------------------------------------------
ID = 17
alias sk_bar_main main
def main
@bars = Window_Sk_Bars.new
sk_bar_main
@bars.dispose if @bars != nil
end
#-----------------------------------------------------------------
alias sk_bar_update update
def update
@bars.update
sk_bar_update
@bars.visible = $game_switches[ID]
end
#-----------------------------------------------------------------
end
#-----------------------------------------------------------------
class Window_Base < Window
#-----------------------------------------------------------------
def sk_initialize(font=0,size=22)
font = "Tahoma" if font == 0
self.contents = Bitmap.new(self.width-32,self.height-32)
self.contents.font.name = font
self.contents.font.size = size
end
#-----------------------------------------------------------------
def draw_text_outline(x,y,w,h,str,c=normal_color,a=0)
self.contents.font.color = Color.new(0,0,0,255)
self.contents.draw_text(x-1,y,w,h,str,a)
self.contents.draw_text(x+1,y,w,h,str,a)
self.contents.draw_text(x,y+1,w,h,str,a)
self.contents.draw_text(x,y-1,w,h,str,a)
self.contents.font.color = c
self.contents.draw_text(x,y,w,h,str,a)
end
#-----------------------------------------------------------------
end
#-----------------------------------------------------------------
class Window_Sk_Bars < Window_Base
#-----------------------------------------------------------------
def initialize
super(444,-8,206,96)
sk_initialize("Arial")
self.opacity = 0
end
#-----------------------------------------------------------------
def update
self.contents.clear
actor = $game_party.actors[0]
return if actor.nil?
draw_text_outline(0,-4,64,26,"HP")
draw_actor_hp(actor,30,0)
end
#-----------------------------------------------------------------
def draw_actor_hp(actor,x,y)
width = 128
y += 4
white = Color.new(255,255,255,255)
black = Color.new(0,0,0,255)
w = width * actor.hp / actor.maxhp
# White border
self.contents.fill_rect(x+1, y-1, width-2, 1, white)
self.contents.fill_rect(x, y, width, 1, white)
self.contents.fill_rect(x-1, y+1, width+2, 9, white)
self.contents.fill_rect(x, y+10, width, 1, white)
self.contents.fill_rect(x+1, y+11, width-2, 1, white)
# Black back
self.contents.fill_rect(x+2, y, width-4, 1, black)
self.contents.fill_rect(x+1, y+1, width-2, 1, black)
self.contents.fill_rect(x, y+2, width, 7, black)
self.contents.fill_rect(x+1, y+9, width-2, 1, black)
self.contents.fill_rect(x+2, y+10, width-4, 1, black)
# Generating the color
val = 255 * ((actor.hp*100)/actor.maxhp)
green = 255 - val/100
color = Color.new(224,green,0,255)
w_color = Color.new(255,green+32,96,255)
if green > 64 then green -= 32
elsif green > 128 then green -= 64 end
b_color = Color.new(172,green,0,255)
# Making the bar
self.contents.fill_rect(x+2, y, w-4, 1, w_color)
self.contents.fill_rect(x+1, y+1, w-2, 1, w_color)
self.contents.fill_rect(x, y+2, w, 7, color)
self.contents.fill_rect(x+1, y+9, w-2, 1, color)
self.contents.fill_rect(x+2, y+10, w-4, 1, b_color)
end
#-----------------------------------------------------------------
end
#-----------------------------------------------------------------
复制代码
作者:
985064351
时间:
2011-7-6 20:22
#==============================================================================
# ■ Window_Actor_Status
#------------------------------------------------------------------------------
# 角色状态
#==============================================================================
ACTOR_STATUS_SWITCH = 1
class Window_Actor_Status < Window_Base
#--------------------------------------------------------------------------
# ● 初始化窗口
#--------------------------------------------------------------------------
def initialize
super(-10,-118, 640, 230)
self.contents = Bitmap.new(width - 32, height - 32)
self.opacity = 0
self.z = 9999
self.contents.font.color = 黑_color
refresh
@old_hp = $game_actors[1].hp
@old_sp = $game_actors[1].sp
cx = contents.text_size($data_system.words.gold).width
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
if $game_switches[ACTOR_STATUS_SWITCH]
@old_hp != $game_actors[1].hp or
@old_sp != $game_actors[1].sp or
@old_exp != $game_actors[1].exp
@old_hp = $game_actors[1].hp
@old_sp = $game_actors[1].sp
cf = 100 * $game_actors[1].now_exp / $game_actors[1].next_exp
cx = contents.text_size($data_system.words.gold).width
self.contents.clear
#=====================================================================#
self.contents.font.size = 12
if $game_actors[1].level < 10
self.contents.draw_text(25,94,32,32,$game_actors[1].level.to_s)
else
self.contents.draw_text(22,94,32,32,$game_actors[1].level.to_s)
end
#=====================================================================#
self.contents.font.size = 11
if $game_actors[1].hp > 1000
self.contents.draw_text(90,107,32,32,$game_actors[1].hp.to_s)
elsif $game_actors[1].hp < 100 && $game_actors[1].hp > 10
self.contents.draw_text(90+10,107,32,32,$game_actors[1].hp.to_s)
elsif $game_actors[1].hp < 10
self.contents.draw_text(90+15,107,32,32,$game_actors[1].hp.to_s)
else
self.contents.draw_text(90+5,107,32,32,$game_actors[1].hp.to_s)
end
self.contents.draw_text(90+10+20,108,32,32,"/")
self.contents.draw_text(90+10+30,107,32,32,$game_actors[1].maxhp.to_s)
bitmap1 = RPG::Cache.picture("血条")
w = bitmap1.width * $game_actors[1].hp / [$game_actors[1].maxhp,1].max
rect1 = Rect.new(0,0,w,bitmap1.height)
self.contents.blt(0,118,bitmap1,rect1)
#=====================================================================#
@plus_sp = 85
if $game_actors[1].sp > 1000
self.contents.draw_text(0+@plus_sp+5,127,32,32,$game_actors[1].sp.to_s)
elsif $game_actors[1].sp < 100 && $game_actors[1].sp > 10
self.contents.draw_text(0+10+@plus_sp+5,127,32,32,$game_actors[1].sp.to_s)
elsif $game_actors[1].sp < 10
self.contents.draw_text(0+15+@plus_sp+5,127,32,32,$game_actors[1].sp.to_s)
else
self.contents.draw_text(0+5+@plus_sp+5,127,32,32,$game_actors[1].sp.to_s)
end
self.contents.draw_text(0+10+20+@plus_sp+5,128,32,32,"/")
self.contents.draw_text(0+10+30+@plus_sp+5,127,32,32,$game_actors[1].maxsp.to_s)
bitmap2 = RPG::Cache.picture("法条")
w = bitmap2.width * $game_actors[1].sp / [$game_actors[1].maxsp,1].max
rect2 = Rect.new(0,0,w,bitmap2.height)
self.contents.blt(-87+bitmap1.width,135,bitmap2,rect2)
#=====================================================================#
@plus_exp = 85*2+20
self.contents.draw_text(-80+@plus_exp,144,22,32,cf.to_s)
bitmap3 = RPG::Cache.picture("经验条")
w = bitmap3.width * $game_actors[1].now_exp / [$game_actors[1].next_exp,1].max
rect3 = Rect.new(0,0,w,bitmap3.height)
self.contents.blt(-173+bitmap1.width+bitmap2.width,152,bitmap3,rect3)
#=========================================================================#
if $game_party.gold >= 0 && $game_party.gold < 99
self.contents.draw_text(100, 165, 120+cx,32, $game_party.gold.to_s)
elsif $game_party.gold >= 99 && $game_party.gold < 999
self.contents.draw_text(96, 165, 120+cx,32, $game_party.gold.to_s)
elsif $game_party.gold >= 999 && $game_party.gold < 9999
self.contents.draw_text(92, 165, 120+cx,32, $game_party.gold.to_s)
elsif $game_party.gold >= 9999 && $game_party.gold < 99999
self.contents.draw_text(88, 165, 120+cx,32, $game_party.gold.to_s)
elsif $game_party.gold >= 99999 && $game_party.gold < 999999
self.contents.draw_text(84, 165, 120+cx,32, $game_party.gold.to_s)
elsif $game_party.gold >= 999999 && $game_party.gold < 9999999
self.contents.draw_text(80, 165, 120+cx,32, $game_party.gold.to_s)
elsif $game_party.gold >= 9999999 && $game_party.gold < 99999999
self.contents.draw_text(76, 165, 120+cx,32, $game_party.gold.to_s)
elsif $game_party.gold >= 99999999 && $game_party.gold < 999999999
self.contents.draw_text(72, 165, 120+cx,32, $game_party.gold.to_s)
elsif $game_party.gold >= 999999999 && $game_party.gold < 9999999999
self.contents.draw_text(68, 165, 120+cx,32, $game_party.gold.to_s)
elsif $game_party.gold >= 9999999999
self.contents.draw_text(10, 165, 120+cx,32, $game_party.gold.to_s)
end
#=========================================================================#
end
end
end
换个吧 HP+SP+经验+金钱 +等级 不要的话 把SP+经验+金钱+等级的删去
R9AFMHA(
[email protected]
(7.01 KB, 下载次数: 2)
下载附件
保存到相册
2011-7-6 20:22 上传
作者:
忧雪の伤
时间:
2011-7-8 14:00
6楼啊喂,
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1