Project1

标题: 如何头像定义ary=[ARYName1..5] [打印本页]

作者: 金芒芒    时间: 2024-5-8 14:56
标题: 如何头像定义ary=[ARYName1..5]
[pre lang="ruby"]
class Spr_map_head < RPG::Spriet  #地图精灵头像类< RPG::精灵
ARY1Name=team_army.member[0-1].captain.character_name#典韦
ARY2Name=team_army.member[4-2].captain.character_name#吕布
ARY3Name=team_army.member[4-3].captain.character_name#曹操
ARY4Name=team_army.member[4-4].captain.character_name#关羽
ARY5Name=team_army.member[4-5].captain.character_name#夏侯渊
ary=[ARY1Name,ARY2Name,ARY3Name,ARY4Name,ARY5Name]
  def initialize(ary,x,y,640,87)#定义初始(人名,x,y,宽=640,间隔=0)
    super()
    self.bitmap = Bitmap.new(640,480)
    self.z = 180
    refresh(ary,x,y,640,87)#刷新(人名,x,y,横,间隔)
  end
  def refresh(ary,x,y,宽=640,间隔=0)#定义(人名,x,y,宽=640,间隔=0)
    self.bitmap.clear#自己位图明确的
    a,b = x,y
    for i in ary.flatten #用于我在进制。压平
      bit = RPG::Cache.picture("头像#{i}") ;w,h = bit.width,bit.height
      (b += h + 间隔 ; a = x) if a + w + 间隔 >= 宽
      self.bitmap.blt(a,b,bit,Rect.new(0,0,w,h))
      a += w + 间隔
    end
  end
end

class Interpreter #解释程序类
  def 显示头像(ary,x,y,宽=640,间隔=0)
    if @head_spr.nil?
      @head_spr = Spr_map_head.new(ary,x,y,宽,间隔)
    else
      @head_spr.refresh(ary,x,y,宽,间隔)
    end
  end
  def 关闭头像
    return if @head_spr.nil?
    @head_spr.dispose ;@head_spr.bitmap.dispose ; @head_spr = nil
  end
  end





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