查看: 1800|回复: 7

战斗头像的问题……

  [复制链接]
梦石
0
星屑
50
在线时间
155 小时
注册时间
2008-5-10
回帖
24
发表于 2008-8-26 19:46:31 | 显示全部楼层 |阅读模式

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

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

×
唉,好不容易把脚本蒙对,头像显示了出来。但战斗中有2个人以上时,游戏速度变慢了,4个人战斗时FTP只剩下5……有没有办法缓解一下……
我在战斗中显示头像的脚本是这么写的

#==============================================================================
# ■ Window_BattleStatus
#------------------------------------------------------------------------------
#  显示战斗画面同伴状态的窗口。
#==============================================================================

class Window_BattleStatus < Window_Base
  #--------------------------------------------------------------------------
  # ● 初始化对像
  #--------------------------------------------------------------------------
  def initialize
    super(0, 320, 640, 160)
    self.opacity = 160
    self.contents = Bitmap.new(width - 32, height - 32)
    @level_up_flags = [false, false, false, false]
    self.opacity = 140
    self.z = 1
    self.contents.font.size = 20   
    refresh
  end
  #--------------------------------------------------------------------------
  # ● 释放
  #--------------------------------------------------------------------------
  def dispose
    super
  end
  #--------------------------------------------------------------------------
  # ● 设置升级标志
  #     actor_index : 角色索引
  #--------------------------------------------------------------------------
  def level_up(actor_index)
    @level_up_flags[actor_index] = true
  end
  #--------------------------------------------------------------------------
  # ● 刷新
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    @item_max = $game_party.actors.size
    for i in 0...$game_party.actors.size
      actor = $game_party.actors
      
      case i
      when 0
      testname = "batter"+actor.id.to_s
      bitmap=Bitmap.new("Graphics/Heads/#{testname}")
      src_rect = Rect.new(0, 0, bitmap.width, bitmap.height)
      self.contents.blt(42, 0, bitmap, src_rect)
      
      when 1
      testname = "batter"+actor.id.to_s
      bitmap=Bitmap.new("Graphics/Heads/#{testname}")
      src_rect = Rect.new(0, 0, bitmap.width, bitmap.height)
      self.contents.blt(202, 0, bitmap, src_rect)

      when 2
      testname = "batter"+actor.id.to_s
      bitmap=Bitmap.new("Graphics/Heads/#{testname}")
      src_rect = Rect.new(0, 0, bitmap.width, bitmap.height)
      self.contents.blt(362, 0, bitmap, src_rect)
      
      when 3
      testname = "batter"+actor.id.to_s
      bitmap=Bitmap.new("Graphics/Heads/#{testname}")
      src_rect = Rect.new(0, 0, bitmap.width, bitmap.height)
      self.contents.blt(522, 0, bitmap, src_rect)
      end
      
      actor_x = i * 160 + 4
      draw_actor_name(actor, actor_x, 0)
      draw_actor_hp(actor, actor_x, 64, 120)#32
      draw_actor_sp(actor, actor_x, 96, 120)#64
      if @level_up_flags
        self.contents.font.color = normal_color
        self.contents.draw_text(actor_x, 32, 120, 32, "等级上升")#96
      else
        draw_actor_state(actor, actor_x, 32)
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● 刷新画面
  #--------------------------------------------------------------------------
  def update
    super
    # 主界面的不透明度下降
    if $game_temp.battle_main_phase
      self.contents_opacity -= 4 if self.contents_opacity > 191
    else
      self.contents_opacity += 4 if self.contents_opacity < 255
    end
  end
end
梦石
0
星屑
42235
在线时间
6017 小时
注册时间
2006-11-10
回帖
6966
发表于 2008-8-27 00:15:57 | 显示全部楼层
for i in 0...$game_party.actors.size
   actor = $game_party.actors
end
testname = "batter"+actor.id.to_s
     bitmap=Bitmap.new("Graphics/Heads/#{testname}")
     src_rect = Rect.new(0, 0, bitmap.width, bitmap.height)
     self.contents.blt(42, 0, bitmap, src_rect)

就可以了~~~~~不用循环判断在分歧= =
回复

使用道具 举报

梦石
0
星屑
50
在线时间
155 小时
注册时间
2008-5-10
回帖
24
 楼主| 发表于 2008-8-27 19:11:52 | 显示全部楼层
不行啊……又变成了如下这样…………
回复

使用道具 举报

孤独守望

梦石
0
星屑
3144
在线时间
1535 小时
注册时间
2006-10-16
回帖
4223

开拓者贵宾

发表于 2008-8-27 19:16:47 | 显示全部楼层
实际上你应该把bitmap的生成放进initialize里面,在refresh里面生成实在是很浪费时间和内存
菩提本非树,明镜本非台。回头自望路漫漫。不求姻缘,但求再见。
本来无一物,何处惹尘埃。风打浪吹雨不来。荒庭遍野,扶摇难接。
不知道多久更新一次的博客
回复

使用道具 举报

梦石
0
星屑
50
在线时间
155 小时
注册时间
2008-5-10
回帖
24
 楼主| 发表于 2008-8-28 01:52:45 | 显示全部楼层
怎么放
回复

使用道具 举报

梦石
0
星屑
50
在线时间
155 小时
注册时间
2008-5-10
回帖
24
 楼主| 发表于 2008-8-29 07:15:45 | 显示全部楼层
又沉了……我不懂得在initialize哪一行加……
回复

使用道具 举报

梦石
0
星屑
50
在线时间
77 小时
注册时间
2008-5-16
回帖
183
发表于 2008-8-29 09:14:37 | 显示全部楼层
在游戏中显示图片会严重拖慢游戏速度。。。尤其是在战斗中。。。。
回复

使用道具 举报

梦石
0
星屑
50
在线时间
155 小时
注册时间
2008-5-10
回帖
24
 楼主| 发表于 2008-8-31 02:13:02 | 显示全部楼层
如果能让显示三个人的头像不卡也行啊~~
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

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

在本版发帖返回顶部