查看: 844|回复: 0

[有事请教] @item_max = 5 每个item的X,y多是独立的

[复制链接]
梦石
0
星屑
7296
在线时间
1244 小时
注册时间
2015-8-15
回帖
473
发表于 2024-6-9 15:28:11 | 显示全部楼层 |阅读模式

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

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

×
如何@text_list.y = 81+45*i + 9和@cur_back.y = 81+45*i  中的y各= 20 50  80  200  150
[pre lang="ruby"]#==============================================================================
# ■ Window_Title_Command
#------------------------------------------------------------------------------
#  标题的主菜单。
#==============================================================================
class Window_Title_Command < Window_Base
  attr_reader   :index
  attr_reader   :slide_over   #滚动结束
  #start load option exit
  #--------------------------------------------------------------------------
  # ● 初始化对像
  #     actor : 角色
  #--------------------------------------------------------------------------
  def initialize(index=0)
    @index = index
    #选项背景
    @button_base = Sprite.new
    @button_base.bitmap = RPG::Cache.title("title-base-light")
    @button_base.x = 409
    @button_base.y = 56
   
   
    @cur_back = []
    @text_list = []
    @able = []
    #光标
    @item_max = 5
    for i in 0...@item_max
      @able = true
      @cur_back = Sprite.new
      @cur_back.bitmap = RPG::Cache.title("title-normal")#+i.to_s)
      @cur_back.x = 435
      @cur_back.y = 81+45*i
      @text_list = Sprite.new
      @text_list.bitmap = RPG::Cache.title("index-"+i.to_s)
      @text_list.x = 435 + 47
      @text_list.y = 81+45*i + 9
    end
    @slide_over = false
    super(0, 0, 0, 0)
    self.opacity = 0
    self.active = true
  end
  def origin_x
    return 435
  end
  def origin_y
    return 81
  end
  #--------------------------------------------------------------------------
  # ● 一些方法的重载
  #--------------------------------------------------------------------------  
  def dispose
    @button_base.dispose
    for i in 0...@item_max
      @cur_back.dispose
      @text_list.dispose
    end
    super
  end
  
  def z=(z)
    super(z)
    @button_base.z=z
    for i in 0...@item_max
      @cur_back.z=z
      @text_list.z=z
    end
  end
  def visible=(visible)
    super(visible)
    @button_base.visible = visible
    for i in 0...@item_max
      @cur_back.visible = visible
      @text_list.visible = visible
    end
  end
  def index=(index)
    @index=index
  end
  def disable_item(i)
  end
  #--------------------------------------------------------------------------
  # ● 光标不被选中状态
  #--------------------------------------------------------------------------
  def back_normal(index)
    if index != -1
       @cur_back[index].bitmap = RPG::Cache.title("title-normal")#+i.to_s)
       @text_list[index].bitmap = RPG::Cache.title("index-"+index.to_s)
    end
  end
  def disable_item(index)
    @cur_back[index].bitmap = RPG::Cache.title("title-pressed")#+i.to_s)
    @able[index] = false
    @text_list[index].bitmap = RPG::Cache.title("index-"+index.to_s+"-black")
    #@cur_back[index].color = Color.new(0,0,0,128)
  end
  #--------------------------------------------------------------------------
  # ● 更新光标矩形
  #--------------------------------------------------------------------------
  def update_cursor_rect
    # 光标位置不满 0 的情况下
    if @index < 0
      for i in 0...@item_max
        back_normal(i)
      end
      return
    end
    @cur_back[@index].bitmap = RPG::Cache.title("title-highlight")#+i.to_s)
    @text_list[@index].bitmap = RPG::Cache.title("index-"+index.to_s+"-hl")
#NAME?
    speed = 40#闪烁速度
    if Graphics.frame_count % speed
      < speed/2
      @cur_back[@index].color = Color.new(255,255,255,100+(Graphics.frame_count%speed)*2)
    else
      @cur_back[@index].color = Color.new(255,255,255,100+(speed-Graphics.frame_count%speed)*2)
    end
#NAME?

  end
  #--------------------------------------------------------------------------
  # ● 刷新画面
  #--------------------------------------------------------------------------
  def update
    #@cur_back.x = 644#640-188
     @slide_over = true

   
    if self.active
      # 方向键左被按下的情况下
      if Input.repeat?(Input::DOWN)
        $game_system.se_play($data_system.cursor_se)
        back_normal(@index)
        @index = (@index+1)%@item_max
        until @able[@index]
          @index = (@index+1)%@item_max
        end
      end
      # 方向键右被按下的情况下
      if Input.repeat?(Input::UP)
        $game_system.se_play($data_system.cursor_se)
        back_normal(@index)
        @index = (@index+@item_max-1)%@item_max
        until @able[@index]
          @index = (@index+@item_max-1)%@item_max
        end
      end
    end
    # 刷新光标矩形
    update_cursor_rect if @slide_over
  end
  
end
[/pre]
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

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

在本版发帖返回顶部