查看: 1397|回复: 0

[已经过期] 为啥我这个显示文本的脚本,一用帧数就下降十多帧?

[复制链接]
梦石
0
星屑
136
在线时间
1050 小时
注册时间
2006-5-3
回帖
602
发表于 2013-4-7 13:46:13 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
本帖最后由 gaofei677 于 2013-4-7 13:53 编辑

这个是我改了来了一个前辈显示变量的脚本,改完以后用起来挺好,但是为什么每次使用这个脚本时的时候,游戏帧数就下降十多帧呢,我我检查了刷新方式,似乎也没什么问题,不是刷新过多的问题。


  1. Context_Switch = 3         
  2. Context_Refrsh = 4  
  3. $draw_context = []

  4. class Draw_Context < Window_Base
  5. #--------------------------------------------------------------------------
  6. # ● 初始化窗口
  7. #--------------------------------------------------------------------------
  8. def initialize
  9.   super(-16, -16, 640+32, 480+32)
  10.   self.contents = Bitmap.new(width - 32, height - 32)
  11.   self.back_opacity = 255  
  12.   self.opacity = 255      
  13.   self.contents_opacity = 255      
  14.   self.visible = false
  15.   self.z=9999
  16.   @draw_context = $draw_context
  17.   @draw_context_a = []
  18.   for draw in $draw_context
  19.     @draw_context_a[draw[0]] = $game_variables[8][draw[0]]
  20.   end   
  21.   refresh
  22. end

  23. #--------------------------------------------------------------------------
  24. # ● 刷新
  25. #--------------------------------------------------------------------------
  26. def refresh
  27.   if $game_switches[Context_Switch]
  28.       @draw_context = $draw_context         
  29.       self.contents.clear
  30.       
  31.       for draw in @draw_context
  32.       @draw_context_a[draw[0]] = $game_variables[8][draw[0]]
  33.      
  34. #==========绝对不是这个部分的问题(start)=========
  35.       #-----------------------------------------------------
  36.       # ● 描绘文字
  37.       #    当文字横排长度>66时,换行描绘
  38.       #    当文字总长度>286时,多余部分不显示
  39.       #-----------------------------------------------------
  40.        a = @draw_context_a[draw[0]].to_s
  41.       
  42.        if a.size > 286
  43.          b = a.slice(a.size-9, a.size)
  44.          a.slice!(273, a.size)
  45.          a.insert(273, "......#{b}")
  46.        end
  47.       
  48.        loop do
  49.          a.gsub!(/\n/) {|s| s=nil }
  50.          break if a.include?("\n") == false
  51.        end
  52.       
  53.       
  54.        if a.size<= 66
  55.          if draw[0] <= 12
  56.            #self.contents.draw_text(draw[1],draw[2],500,35,a)
  57.            self.contents.draw_text(draw[1],draw[2],a.size*10,35,a)
  58.            contents.font.size = 20
  59.            if draw[0] == 5 or draw[0] == 11
  60.              contents.font.color.set(0,255,255,245)
  61.            else
  62.              contents.font.color.set(255,255,255,245)
  63.            end
  64.          else
  65.             if draw[0] == 27 && a.size == 6
  66.                draw[1] = 463
  67.             end
  68.            #self.contents.draw_text(draw[1],draw[2],500,35,a)
  69.            self.contents.draw_text(draw[1],draw[2],a.size*10,35,a)
  70.            contents.font.color.set(0,0,0,245)
  71.            contents.font.shadow = false
  72.            contents.font.name = ["幼圆"]
  73.            if draw[0] == 24 or draw[0] == 25
  74.              contents.font.size = 13
  75.              contents.font.shadow = true
  76.              contents.font.color.set(255,255,255,255)
  77.            elsif draw[0] == 23
  78.              contents.font.color.set(255,255,255,255)
  79.              contents.font.size = 19
  80.                
  81.            elsif draw[0] == 26
  82.              contents.font.color.set(255,255,255,200)
  83.              contents.font.size = 17
  84.            elsif draw[0] == 13
  85.              contents.font.color.set(255,255,255,255)
  86.              contents.font.size = 15
  87.             
  88.            elsif draw[0] == 35
  89.              contents.font.color.set(255,0,0,255)
  90.              if $white[8] == true
  91.                  contents.font.color.set(0,255,0,255)
  92.              end
  93.            elsif draw[0] == 38
  94.              contents.font.color.set(255,0,0,0)

  95.            elsif draw[0] == 36
  96.                  contents.font.color.set(255,0,0,255)
  97.              if $white[9] == true
  98.                  contents.font.color.set(0,255,0,255)
  99.              end
  100.             
  101.            elsif draw[0] == 37  
  102.              if $white[10] == true
  103.                contents.font.color.set(0,255,0,255)
  104.              else
  105.                contents.font.color.set(255,0,0,255)
  106.              end
  107.            else
  108.              contents.font.color.set(100,0,0,150)
  109.              contents.font.size = 17
  110.            end
  111.            
  112.           end
  113.         end
  114.       
  115.         
  116.        if a.size> 66
  117.          line = 0
  118.          loop do
  119.            b = a[0+line*66, 66]
  120.            self.contents.draw_text(draw[1],draw[2]+20*line,500,35,b)
  121.            line += 1
  122.            break if line >= 5
  123.          end
  124.            contents.font.color.set(0,0,0,245)
  125.            contents.font.shadow = false
  126.            contents.font.name = ["幼圆"]
  127.         end
  128. #==========绝对不是这个部分的问题(end)=========


  129.     end
  130.   end
  131. end
  132. #--------------------------------------------------------------------------
  133. # ● 判断文字刷新
  134. #--------------------------------------------------------------------------
  135. def judge
  136.   for draw in $draw_context
  137.     if @draw_context_a[draw[0]] != $game_variables[8][draw[0]]
  138.       return true
  139.     end
  140.   end
  141.   if $game_switches[Context_Refrsh]  
  142.      $game_switches[Context_Refrsh] = false
  143.      return true
  144.   end
  145.   return false
  146. end
  147. end

  148. class Scene_Map
  149. alias  old_start start
  150. def start
  151. old_start
  152.   @draw_context = Draw_Context.new
  153.   @draw_context.opacity = 0
  154. end
  155. #--------------------------------------------------------------------------
  156. # ● 刷新画面
  157. #--------------------------------------------------------------------------
  158. alias draw_context_update update
  159. def update
  160.   draw_context_update
  161.   if $game_switches[Context_Switch]
  162.     @draw_context.visible = true      
  163.     @draw_context.refresh if @draw_context.judge
  164.   else
  165.     @draw_context.visible = false
  166.   end
  167. end
  168. end
复制代码
漏夏同人
《咱的夏天》
下载地址:http://tieba.baidu.com/p/2681607456
人员招募:http://rpg.blue/thread-339747-1-1.html
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部