Project1

标题: 这个脚本影响帧数,请教有什么优化的办法 [打印本页]

作者: 幻耶    时间: 2009-12-11 13:12
标题: 这个脚本影响帧数,请教有什么优化的办法
本帖最后由 幻耶 于 2009-12-11 13:37 编辑

这个脚本的效果是当某开关打开,相应的事件闪烁不同的颜色,严重影响游戏帧数,症状是在游戏中进一下别的地图再回原地图,速度会变得很卡,帧数下降到11左右!但是这效果我又不想放弃,有什么优化的办法么
  1. Goahead1_Color = [255,0,0] #颜色红色[R,G,B]
  2. Goahead1_Count = 20 # 闪烁间隔
  3. Goahead2_Color = [0,0,255] #颜色蓝色[R,G,B]
  4. Goahead2_Count = 20 # 闪烁间隔
  5. Goahead3_Color = [255,0,255] #颜色紫色[R,G,B]
  6. Goahead3_Count = 20 # 闪烁间隔
  7. Goahead4_Color = [0,255,0] #颜色绿色[R,G,B]
  8. Goahead4_Count = 20 # 闪烁间隔
  9. Goahead5_Color = [255,255,0] #颜色黄色[R,G,B]
  10. Goahead5_Count = 20 # 闪烁间隔
  11. Goahead6_Color = [0,255,255] #颜色浅蓝色[R,G,B]
  12. Goahead6_Count = 20 # 闪烁间隔

  13. class Sprite_Character < RPG::Sprite
  14.   #燃烧持续扣血
  15.   def update_tone1
  16.     @count ||= Goahead1_Count
  17.     if @count <= 0
  18.       @count = Goahead1_Count
  19.       for i in 1..20
  20.         if @character.moving? and @character.id == i and $game_switches[i+600] == true
  21.           name = $game_map.events[i].name
  22.           data = name.split(/,/)
  23.           data[1] = data[1].to_i - $game_variables[31] - 20
  24.           $game_map.events[i].name = data[0].to_s+","+data[1].to_s+","+data[2].to_s+","+data[3].to_s+","+data[4].to_s+","+data[5].to_s+","+data[6].to_s+","+data[7].to_s+","+data[8].to_s
  25.         end
  26.       end
  27.     else
  28.       @count -= 1
  29.     end
  30.     if @count < Goahead1_Count/2
  31.       self.tone.set(*Goahead1_Color)
  32.     else
  33.       self.tone.set(0,0,0,0)
  34.     end
  35.   end

  36.   #冰冻减慢速度
  37.   def update_tone2
  38.     @count ||= Goahead2_Count
  39.     if @count <= 0
  40.       @count = Goahead2_Count
  41.       for i in 1..20
  42.         if @character.moving? and @character.id == i and $game_switches[i+625] == true
  43.           $game_map.events[i].move_speed = 1
  44.         end
  45.       end
  46.     else
  47.       @count -= 1
  48.     end
  49.     if @count < Goahead2_Count/2
  50.       self.tone.set(*Goahead2_Color)
  51.     else
  52.       self.tone.set(0,0,0,0)
  53.     end
  54.   end
  55.   
  56.   #麻痹原地打转
  57.   def update_tone3
  58.     @count ||= Goahead3_Count
  59.     if @count <= 0
  60.       @count = Goahead3_Count
  61.       for i in 1..20
  62.         if @character.moving? and @character.id == i and $game_switches[i+650] == true
  63.           $game_map.events[i].move_speed = 0
  64.         end
  65.       end
  66.     else
  67.       @count -= 1
  68.     end
  69.     if @count < Goahead3_Count/2
  70.       self.tone.set(*Goahead3_Color)
  71.     else
  72.       self.tone.set(0,0,0,0)
  73.     end
  74.   end
  75.   
  76.   #中毒持续扣血
  77.   def update_tone4
  78.     @count ||= Goahead4_Count
  79.     if @count <= 0
  80.       @count = Goahead4_Count
  81.       for i in 1..20
  82.         if @character.moving? and @character.id == i and $game_switches[i+675] == true
  83.           name = $game_map.events[i].name
  84.           data = name.split(/,/)

  85.           data[1] = data[1].to_i - $game_variables[34]
  86.           $game_map.events[i].name = data[0].to_s+","+data[1].to_s+","+data[2].to_s+","+data[3].to_s+","+data[4].to_s+","+data[5].to_s+","+data[6].to_s+","+data[7].to_s+","+data[8].to_s
  87.         end
  88.       end
  89.     else
  90.       @count -= 1
  91.     end
  92.     if @count < Goahead4_Count/2
  93.       self.tone.set(*Goahead4_Color)
  94.     else
  95.       self.tone.set(0,0,0,0)
  96.     end
  97.   end
  98.   
  99.   
  100.   
  101.   
  102.   
  103.   alias goahead1_update update
  104.   def update
  105.     reset = true
  106.     for i in 1..20
  107.     if @character.is_a?(Game_Event) and @character.id == i and $game_switches[i+600] == true
  108.       update_tone1
  109.       reset = false
  110.     end
  111.     if @character.is_a?(Game_Event) and @character.id == i and $game_switches[i+625] == true
  112.       update_tone2
  113.       reset = false
  114.     end
  115.     if @character.is_a?(Game_Event) and @character.id == i and $game_switches[i+650] == true
  116.       update_tone3
  117.       reset = false
  118.     end
  119.     if @character.is_a?(Game_Event) and @character.id == i and $game_switches[i+675] == true
  120.       update_tone4
  121.       reset = false
  122.     end
  123.     if @character.is_a?(Game_Event) and @character.id == i and $game_switches[i+700] == true
  124.       update_tone5
  125.       reset = false
  126.     end
  127.     if @character.is_a?(Game_Event) and @character.id == i and $game_switches[i+725] == true
  128.       update_tone6
  129.       reset = false
  130.     end
  131.     self.tone.set(0, 0, 0) if reset
  132.     end
  133.     goahead1_update
  134.   end
  135. end
复制代码

作者: goahead    时间: 2009-12-11 15:00
提示: 作者被禁止或删除 内容自动屏蔽
作者: 幻耶    时间: 2009-12-11 15:03
好像是你写的吧。。。我乱改了一下~:funk:
求优化




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1