Project1

标题: 窗口模式改成精灵模式 [打印本页]

作者: 金芒芒    时间: 2023-6-17 16:19
标题: 窗口模式改成精灵模式
#==============================================================================
# ■ Window_db
#------------------------------------------------------------------------------
#  显示队标动画的窗口
#==============================================================================

class Window_db < Window_Base
  #--------------------------------------------------------------------------
  # ● 初始化目标
  #--------------------------------------------------------------------------
  def initialize
    super((640-60)/2-16, (480-90)/2-16-64, 60, 90)
    self.contents = Bitmap.new(width - 32, height - 32)
    @count = @kind = 0
    # 隐藏窗口可见度
    self.opacity = 0
    self.z = 350
    refresh
  end
  #--------------------------------------------------------------------------
  # ● 刷新
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    # 队标显示
    refresh_sprite(0, 0, @kind)
  end
  #---------------------------------------------------------------------------
  # ● 刷新人物动态图
  #---------------------------------------------------------------------------
  def update
    super
    self.x = $game_player.screen_x-96
    self.y = $game_player.screen_y-20
    self.visible = (a=($game_party.actors[0] || $game_actors[1])).hp >= a.maxhp * 0.05
    @count += 1
    # 设置图片刷新速度
    @count = 0 if @count >= 30
    if @count / 2 != @kind
      @kind = @count / 2
      refresh
    end
  end
end

#==============================================================================
# ■ Window_Base
#------------------------------------------------------------------------------
#  游戏中全部窗口的超级类。
#==============================================================================

class Window_Base < Window
  #--------------------------------------------------------------------------
  # ● 初始化对像
  #     x      : 窗口的 X 坐标
  #     y      : 窗口的 Y 坐标
  #     width  : 窗口的宽
  #     height : 窗口的宽
  #--------------------------------------------------------------------------  
  def refresh_sprite(x, y, kind)
    bitmap = RPG::Cache.picture("图片显示/动态图/队标")
    w = bitmap.width / 15
    src_rect = Rect.new(kind * w, 0, w, bitmap.height)
    self.contents.blt(x, y, bitmap, src_rect)
  end
end




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