赞 | 0 |
VIP | 12 |
好人卡 | 5 |
积分 | 1 |
经验 | 43535 |
最后登录 | 2020-11-2 |
在线时间 | 1050 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 136
- 在线时间
- 1050 小时
- 注册时间
- 2006-5-3
- 帖子
- 774
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
本帖最后由 gaofei677 于 2013-4-7 13:53 编辑
这个是我改了来了一个前辈显示变量的脚本,改完以后用起来挺好,但是为什么每次使用这个脚本时的时候,游戏帧数就下降十多帧呢,我我检查了刷新方式,似乎也没什么问题,不是刷新过多的问题。
Context_Switch = 3 Context_Refrsh = 4 $draw_context = [] class Draw_Context < Window_Base #-------------------------------------------------------------------------- # ● 初始化窗口 #-------------------------------------------------------------------------- def initialize super(-16, -16, 640+32, 480+32) self.contents = Bitmap.new(width - 32, height - 32) self.back_opacity = 255 self.opacity = 255 self.contents_opacity = 255 self.visible = false self.z=9999 @draw_context = $draw_context @draw_context_a = [] for draw in $draw_context @draw_context_a[draw[0]] = $game_variables[8][draw[0]] end refresh end #-------------------------------------------------------------------------- # ● 刷新 #-------------------------------------------------------------------------- def refresh if $game_switches[Context_Switch] @draw_context = $draw_context self.contents.clear for draw in @draw_context @draw_context_a[draw[0]] = $game_variables[8][draw[0]] #==========绝对不是这个部分的问题(start)========= #----------------------------------------------------- # ● 描绘文字 # 当文字横排长度>66时,换行描绘 # 当文字总长度>286时,多余部分不显示 #----------------------------------------------------- a = @draw_context_a[draw[0]].to_s if a.size > 286 b = a.slice(a.size-9, a.size) a.slice!(273, a.size) a.insert(273, "......#{b}") end loop do a.gsub!(/\n/) {|s| s=nil } break if a.include?("\n") == false end if a.size<= 66 if draw[0] <= 12 #self.contents.draw_text(draw[1],draw[2],500,35,a) self.contents.draw_text(draw[1],draw[2],a.size*10,35,a) contents.font.size = 20 if draw[0] == 5 or draw[0] == 11 contents.font.color.set(0,255,255,245) else contents.font.color.set(255,255,255,245) end else if draw[0] == 27 && a.size == 6 draw[1] = 463 end #self.contents.draw_text(draw[1],draw[2],500,35,a) self.contents.draw_text(draw[1],draw[2],a.size*10,35,a) contents.font.color.set(0,0,0,245) contents.font.shadow = false contents.font.name = ["幼圆"] if draw[0] == 24 or draw[0] == 25 contents.font.size = 13 contents.font.shadow = true contents.font.color.set(255,255,255,255) elsif draw[0] == 23 contents.font.color.set(255,255,255,255) contents.font.size = 19 elsif draw[0] == 26 contents.font.color.set(255,255,255,200) contents.font.size = 17 elsif draw[0] == 13 contents.font.color.set(255,255,255,255) contents.font.size = 15 elsif draw[0] == 35 contents.font.color.set(255,0,0,255) if $white[8] == true contents.font.color.set(0,255,0,255) end elsif draw[0] == 38 contents.font.color.set(255,0,0,0) elsif draw[0] == 36 contents.font.color.set(255,0,0,255) if $white[9] == true contents.font.color.set(0,255,0,255) end elsif draw[0] == 37 if $white[10] == true contents.font.color.set(0,255,0,255) else contents.font.color.set(255,0,0,255) end else contents.font.color.set(100,0,0,150) contents.font.size = 17 end end end if a.size> 66 line = 0 loop do b = a[0+line*66, 66] self.contents.draw_text(draw[1],draw[2]+20*line,500,35,b) line += 1 break if line >= 5 end contents.font.color.set(0,0,0,245) contents.font.shadow = false contents.font.name = ["幼圆"] end #==========绝对不是这个部分的问题(end)========= end end end #-------------------------------------------------------------------------- # ● 判断文字刷新 #-------------------------------------------------------------------------- def judge for draw in $draw_context if @draw_context_a[draw[0]] != $game_variables[8][draw[0]] return true end end if $game_switches[Context_Refrsh] $game_switches[Context_Refrsh] = false return true end return false end end class Scene_Map alias old_start start def start old_start @draw_context = Draw_Context.new @draw_context.opacity = 0 end #-------------------------------------------------------------------------- # ● 刷新画面 #-------------------------------------------------------------------------- alias draw_context_update update def update draw_context_update if $game_switches[Context_Switch] @draw_context.visible = true @draw_context.refresh if @draw_context.judge else @draw_context.visible = false end end end
Context_Switch = 3
Context_Refrsh = 4
$draw_context = []
class Draw_Context < Window_Base
#--------------------------------------------------------------------------
# ● 初始化窗口
#--------------------------------------------------------------------------
def initialize
super(-16, -16, 640+32, 480+32)
self.contents = Bitmap.new(width - 32, height - 32)
self.back_opacity = 255
self.opacity = 255
self.contents_opacity = 255
self.visible = false
self.z=9999
@draw_context = $draw_context
@draw_context_a = []
for draw in $draw_context
@draw_context_a[draw[0]] = $game_variables[8][draw[0]]
end
refresh
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
if $game_switches[Context_Switch]
@draw_context = $draw_context
self.contents.clear
for draw in @draw_context
@draw_context_a[draw[0]] = $game_variables[8][draw[0]]
#==========绝对不是这个部分的问题(start)=========
#-----------------------------------------------------
# ● 描绘文字
# 当文字横排长度>66时,换行描绘
# 当文字总长度>286时,多余部分不显示
#-----------------------------------------------------
a = @draw_context_a[draw[0]].to_s
if a.size > 286
b = a.slice(a.size-9, a.size)
a.slice!(273, a.size)
a.insert(273, "......#{b}")
end
loop do
a.gsub!(/\n/) {|s| s=nil }
break if a.include?("\n") == false
end
if a.size<= 66
if draw[0] <= 12
#self.contents.draw_text(draw[1],draw[2],500,35,a)
self.contents.draw_text(draw[1],draw[2],a.size*10,35,a)
contents.font.size = 20
if draw[0] == 5 or draw[0] == 11
contents.font.color.set(0,255,255,245)
else
contents.font.color.set(255,255,255,245)
end
else
if draw[0] == 27 && a.size == 6
draw[1] = 463
end
#self.contents.draw_text(draw[1],draw[2],500,35,a)
self.contents.draw_text(draw[1],draw[2],a.size*10,35,a)
contents.font.color.set(0,0,0,245)
contents.font.shadow = false
contents.font.name = ["幼圆"]
if draw[0] == 24 or draw[0] == 25
contents.font.size = 13
contents.font.shadow = true
contents.font.color.set(255,255,255,255)
elsif draw[0] == 23
contents.font.color.set(255,255,255,255)
contents.font.size = 19
elsif draw[0] == 26
contents.font.color.set(255,255,255,200)
contents.font.size = 17
elsif draw[0] == 13
contents.font.color.set(255,255,255,255)
contents.font.size = 15
elsif draw[0] == 35
contents.font.color.set(255,0,0,255)
if $white[8] == true
contents.font.color.set(0,255,0,255)
end
elsif draw[0] == 38
contents.font.color.set(255,0,0,0)
elsif draw[0] == 36
contents.font.color.set(255,0,0,255)
if $white[9] == true
contents.font.color.set(0,255,0,255)
end
elsif draw[0] == 37
if $white[10] == true
contents.font.color.set(0,255,0,255)
else
contents.font.color.set(255,0,0,255)
end
else
contents.font.color.set(100,0,0,150)
contents.font.size = 17
end
end
end
if a.size> 66
line = 0
loop do
b = a[0+line*66, 66]
self.contents.draw_text(draw[1],draw[2]+20*line,500,35,b)
line += 1
break if line >= 5
end
contents.font.color.set(0,0,0,245)
contents.font.shadow = false
contents.font.name = ["幼圆"]
end
#==========绝对不是这个部分的问题(end)=========
end
end
end
#--------------------------------------------------------------------------
# ● 判断文字刷新
#--------------------------------------------------------------------------
def judge
for draw in $draw_context
if @draw_context_a[draw[0]] != $game_variables[8][draw[0]]
return true
end
end
if $game_switches[Context_Refrsh]
$game_switches[Context_Refrsh] = false
return true
end
return false
end
end
class Scene_Map
alias old_start start
def start
old_start
@draw_context = Draw_Context.new
@draw_context.opacity = 0
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
alias draw_context_update update
def update
draw_context_update
if $game_switches[Context_Switch]
@draw_context.visible = true
@draw_context.refresh if @draw_context.judge
else
@draw_context.visible = false
end
end
end
|
|