Project1

标题: 菜单界面箭头【不知道怎么在标题描述这个问题- -】 [打印本页]

作者: saturnfjh    时间: 2012-3-29 09:54
标题: 菜单界面箭头【不知道怎么在标题描述这个问题- -】
先上图:



请注意任务状态下的 箭头 “↓”

我想把它改成左右滚动而不是上下改动,并且每次滚动只移动1个index而不是翻页(4个index),求指教……
作者: 殇殃    时间: 2012-3-29 10:19
目测楼主的菜单画面显示队员的那个窗口是修改Window_MenuStatus的
class Window_MenuStatus < Window_Selectable

  #--------------------------------------------------------------------------
  # ● 获取列数
# 关键是增加此函数,其他细微的修改自己摸索吧
#--------------------------------------------------------------------------
  def col_max
    return 4#一行显示4个角色
end

end
作者: saturnfjh    时间: 2012-3-29 10:53
@殇殃

箭头什么的搞定了,但是现在的问题是col_max
如果定义col_max为4的话,当队员超出4名时,光标会移出画面外并且画面不会卷动;如果定义col_max为item_max的话又显得太挤了- -
作者: hcm    时间: 2012-3-29 10:57
你指的是在队员多过4人时,可以左右移动来查看替补队员吗?
作者: 345912390    时间: 2012-3-29 11:19
提供你一个思路:1参考横向命令脚本限制光标移动
2扩大容器宽度,限制其高度
手机不好写教本,我明天会写这个的修改教程
作者: saturnfjh    时间: 2012-3-29 11:23
@hcm


其实后面两个空白位是有人的,但是描绘不出来,光标可以移动,求解……

附上脚本:
  1. #encoding:utf-8
  2. #==============================================================================
  3. # ■ Window_MenuStatus
  4. #------------------------------------------------------------------------------
  5. #  菜单画面中,显示队伍成员状态的窗口
  6. #==============================================================================

  7. class Window_MenuStatus < Window_Selectable
  8.   #--------------------------------------------------------------------------
  9.   # ● 定义实例变量
  10.   #--------------------------------------------------------------------------
  11.   attr_reader   :pending_index            # 保留位置(整队用)
  12.   #--------------------------------------------------------------------------
  13.   # ● 初始化对象
  14.   #--------------------------------------------------------------------------
  15.   def initialize(x, y)
  16.     super(x, y, window_width, window_height)
  17.     @pending_index = -1
  18.     refresh
  19.   end
  20.   #--------------------------------------------------------------------------
  21.   # ● 获取一页內显示的行数
  22.   #--------------------------------------------------------------------------
  23.   def page_row_max
  24.     1
  25.   end
  26.   #--------------------------------------------------------------------------
  27.   # ● 获取行数
  28.   #--------------------------------------------------------------------------
  29.   def row_max
  30.     1
  31.   end
  32.   #--------------------------------------------------------------------------
  33.   # ● 获取窗口的宽度
  34.   #--------------------------------------------------------------------------
  35.   def window_width
  36.     Graphics.width
  37.   end
  38.   #--------------------------------------------------------------------------
  39.   # ● 获取窗口的高度
  40.   #--------------------------------------------------------------------------
  41.   def window_height
  42.     Graphics.height - 96
  43.   end
  44.   #--------------------------------------------------------------------------
  45.   # ● 获取项目数
  46.   #--------------------------------------------------------------------------
  47.   def item_max
  48.     $game_party.members.size
  49.   end
  50.   def col_max
  51.     4
  52.   end
  53.   #--------------------------------------------------------------------------
  54.   # ● 获取项目的绘制矩形
  55.   #--------------------------------------------------------------------------
  56.   def item_rect(index)
  57.     rect = Rect.new
  58.     rect.width = item_width
  59.     rect.height = item_height
  60.     rect.x = index * (item_width + spacing)
  61.     rect.y = index / item_max * item_height
  62.     rect
  63.   end
  64.   #--------------------------------------------------------------------------
  65.   # ● 获取项目的高度
  66.   #--------------------------------------------------------------------------
  67.   def item_height
  68.     Graphics.height - 120
  69.   end
  70.   #--------------------------------------------------------------------------
  71.   # ● 绘制项目
  72.   #--------------------------------------------------------------------------
  73.   def draw_item(index)
  74.     actor = $game_party.members[index]
  75.     enabled = $game_party.battle_members.include?(actor)
  76.     rect = item_rect(index)
  77.     draw_item_background(index)
  78.     draw_actor_name_ms(actor, rect.x + 1, rect.y + 1)
  79.     change_color(system_color)
  80.     contents.fill_rect(rect.x, rect.y + 35, 120, 2, line_color)
  81.     contents.fill_rect(rect.x, rect.y + 203, 120, 2, line_color)
  82.     contents.fill_rect(rect.x, rect.y + 349, 120, 2, line_color)
  83.     change_color(normal_color)
  84.     draw_actor_class_ms(actor, rect.x + 1, rect.y + 48)
  85.     draw_actor_face(actor, rect.x + 12, rect.y + 84, enabled)
  86.     draw_actor_simple_status_2(actor, rect.x + 1, rect.y + 216)
  87.   end
  88.   #--------------------------------------------------------------------------
  89.   # ● 获取水平线的颜色
  90.   #--------------------------------------------------------------------------
  91.   def line_color
  92.     color = normal_color
  93.     color.alpha = 48
  94.     color
  95.   end
  96.   #--------------------------------------------------------------------------
  97.   # ● 绘制简单的状态
  98.   #--------------------------------------------------------------------------
  99.   def draw_actor_simple_status_2(actor, x, y)
  100.     draw_actor_level_ms(actor, x , y)
  101.     draw_actor_icons(actor, x, y + line_height * 1, width =120)
  102.     draw_actor_hp(actor, x, y + line_height * 2, width = 120)
  103.     draw_actor_mp(actor, x, y + line_height * 3, width = 120)
  104.     draw_exp_ms(actor, x, y + line_height * 4, width = 120)
  105.   end
  106.   #--------------------------------------------------------------------------
  107.   # ● 経験値情報の描画
  108.   #--------------------------------------------------------------------------
  109.   def draw_exp_ms(actor, x, y, width)
  110.     s_next = sprintf(Vocab::ExpNext, Vocab::level)
  111.     change_color(normal_color)
  112.     draw_actor_exp_gauge(actor, x, y, width)
  113.     change_color(system_color)
  114.     draw_text(x, y + line_height * 0, width, line_height, s_next)
  115.     change_color(normal_color)
  116.     draw_text(x, y + line_height * 0, width, line_height, (actor.exp_rate * 100).round.to_s + "%", 2)
  117.   end
  118.   #--------------------------------------------------------------------------
  119.   # ● 绘制项目的背景
  120.   #--------------------------------------------------------------------------
  121.   def draw_item_background(index)
  122.     if index == @pending_index
  123.       contents.fill_rect(item_rect(index), pending_color)
  124.     end
  125.   end
  126.   #--------------------------------------------------------------------------
  127.   # ● 按下确定键时的处理
  128.   #--------------------------------------------------------------------------
  129.   def process_ok
  130.     super
  131.     $game_party.menu_actor = $game_party.members[index]
  132.   end
  133.   #--------------------------------------------------------------------------
  134.   # ● 返回上一个选择的位置
  135.   #--------------------------------------------------------------------------
  136.   def select_last
  137.     select($game_party.menu_actor.index || 0)
  138.   end
  139.   #--------------------------------------------------------------------------
  140.   # ● 设置保留位置(整队用)
  141.   #--------------------------------------------------------------------------
  142.   def pending_index=(index)
  143.     last_pending_index = @pending_index
  144.     @pending_index = index
  145.     redraw_item(@pending_index)
  146.     redraw_item(last_pending_index)
  147.   end
  148.   #--------------------------------------------------------------------------
  149.   # ● 绘制名字
  150.   #--------------------------------------------------------------------------
  151.   def draw_actor_name_ms(actor, x, y, width = 120)
  152.     change_color(hp_color(actor))
  153.     draw_text(x, y, width, line_height, actor.name, 1)
  154.   end
  155.   #--------------------------------------------------------------------------
  156.   # ● 绘制职业
  157.   #--------------------------------------------------------------------------
  158.   def draw_actor_class_ms(actor, x, y, width = 120)
  159.     change_color(normal_color)
  160.     draw_text(x, y, width, line_height, actor.class.name, 1)
  161.   end
  162.   #--------------------------------------------------------------------------
  163.   # ● 绘制等级
  164.   #--------------------------------------------------------------------------
  165.   def draw_actor_level_ms(actor, x, y)
  166.     change_color(system_color)
  167.     draw_text(x, y, 32, line_height, Vocab::level_a)
  168.     change_color(normal_color)
  169.     draw_text(x + 32, y, 88, line_height, actor.level, 2)
  170.   end
  171.   
  172.   #--------------------------------------------------------------------------
  173.   # ● 光标向下移动
  174.   #--------------------------------------------------------------------------
  175.   def cursor_down(wrap = false)
  176.     if index < item_max - 1
  177.       select(index + 1)
  178.     else
  179.       select(0)
  180.     end
  181.   end
  182.   #--------------------------------------------------------------------------
  183.   # ● 光标向上移动
  184.   #--------------------------------------------------------------------------
  185.   def cursor_up(wrap = false)
  186.     if index == 0
  187.       select(item_max - 1)
  188.     else
  189.       select(index - 1)
  190.     end
  191.   end
  192.   #--------------------------------------------------------------------------
  193.   # ● 光标向右移动
  194.   #--------------------------------------------------------------------------
  195.   def cursor_right(wrap = false)
  196.     if index < item_max - 1
  197.       select(index + 1)
  198.     else
  199.       select(0)
  200.     end
  201.   end
  202.   #--------------------------------------------------------------------------
  203.   # ● 光标向左移动
  204.   #--------------------------------------------------------------------------
  205.   def cursor_left(wrap = false)
  206.     if index == 0
  207.       select(item_max - 1)
  208.     else
  209.       select(index - 1)
  210.     end
  211.   end
  212.   #--------------------------------------------------------------------------
  213.   # ● 光标移至下一页
  214.   #--------------------------------------------------------------------------
  215.   def cursor_pagedown
  216.     if top_row + page_row_max < row_max
  217.       self.top_row += page_row_max
  218.       select([@index + page_item_max, item_max - 1].min)
  219.     end
  220.   end
  221.   #--------------------------------------------------------------------------
  222.   # ● 光标移至上一页
  223.   #--------------------------------------------------------------------------
  224.   def cursor_pageup
  225.     if top_row > 0
  226.       self.top_row -= page_row_max
  227.       select([@index - page_item_max, 0].max)
  228.     end
  229.   end
  230. #===============================================================================
  231.   #--------------------------------------------------------------------------
  232.   # ● 获取当前行
  233.   #--------------------------------------------------------------------------
  234.   def col
  235.     index
  236.   end
  237.   #--------------------------------------------------------------------------
  238.   # ● 获取顶行位置
  239.   #--------------------------------------------------------------------------
  240.   def top_col
  241.     ox / item_width
  242.   end
  243.   #--------------------------------------------------------------------------
  244.   # ● 设置顶行位置
  245.   #--------------------------------------------------------------------------
  246.   def top_col=(col)
  247.     col = 0 if col < 0
  248.     col = col_max - 1 if col > col_max - 1
  249.     self.ox = col * (item_width + spacing)
  250.   end
  251.   #--------------------------------------------------------------------------
  252.   # ● 获取末行位置
  253.   #--------------------------------------------------------------------------
  254.   def bottom_col
  255.     top_col + 3
  256.   end
  257.   #--------------------------------------------------------------------------
  258.   # ● 设置末行位置
  259.   #--------------------------------------------------------------------------
  260.   def bottom_col=(col)
  261.     self.top_col = col - 3
  262.   end
  263.   #--------------------------------------------------------------------------
  264.   # ● 确保光标在画面范围内滚动
  265.   #--------------------------------------------------------------------------
  266.   def ensure_cursor_visible
  267.     self.top_col = col if col < top_col
  268.     self.bottom_col = col if col > bottom_col
  269.   end
  270. end
复制代码





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