Project1

标题: 关于选择项横着选择 [打印本页]

作者: 毛欢    时间: 2011-4-24 20:12
标题: 关于选择项横着选择
本帖最后由 毛欢 于 2011-4-26 18:18 编辑

选择项横着选择

这个相关的脚本:


    # 生成命令窗口
    s1 = $data_system.words.item
    s2 = $data_system.words.skill
    s3 = $data_system.words.equip
    s4 = "状态"
    s5 = "存档"
    s6 = "结束游戏"
    @command_window = Window_Command.new(640, [s1, s2, s3, s4, s5, s6])
    @command_window.index = @menu_index
    @command_window.x = 0
    @command_window.y = 412
    @command_window.opacity = 150


急求高手帮助!谢谢
(不要给我范例啊最好直接给我脚本谢谢)
作者: a19981007a    时间: 2011-4-26 13:47
打多点空格啊.....
作者: 沙漠点灰    时间: 2011-4-26 18:03
回复 毛欢 的帖子

脚本默认Window_Commad是竖着显示的,我们可以对他进行修改就可实现横着选择...
比如:
  1. #==============================================================================
  2. # ■ Window_Command
  3. #------------------------------------------------------------------------------
  4. #  一般的命令选择行窗口。
  5. #==============================================================================

  6. class Window_Command < Window_Selectable
  7.   #--------------------------------------------------------------------------
  8.   # ● 初始化对像
  9.   #     width    : 窗口的宽
  10.   #     commands : 命令字符串序列
  11.   #--------------------------------------------------------------------------
  12.   def initialize(width, commands, column_max=1)
  13.     # 由命令的个数计算出窗口的高
  14.     super(0, 0, width, (commands.size / column_max.to_f).ceil*32  + 32)
  15.     @item_max = commands.size
  16.     @commands = commands
  17.     @column_max = column_max
  18.     self.contents = Bitmap.new(width - 32, (@item_max.to_f/column_max).ceil* 32)
  19.     refresh
  20.     self.index = 0
  21.   end
  22.   #--------------------------------------------------------------------------
  23.   # ● 刷新
  24.   #--------------------------------------------------------------------------
  25.   def refresh
  26.     self.contents.clear
  27.     for i in 0...@item_max
  28.       draw_item(i, normal_color)
  29.     end
  30.   end
  31.   #--------------------------------------------------------------------------
  32.   # ● 描绘项目
  33.   #     index : 项目编号
  34.   #     color : 文字色
  35.   #--------------------------------------------------------------------------
  36.   def draw_item(index, color)
  37.     self.contents.font.color = color
  38.     rect = Rect.new(4+index%@column_max*self.width/@column_max,
  39.              32 * (index/@column_max), self.width - 8, 32)
  40.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  41.     self.contents.draw_text(rect, @commands[index])
  42.   end
  43.   #--------------------------------------------------------------------------
  44.   # ● 项目无效化
  45.   #     index : 项目编号
  46.   #--------------------------------------------------------------------------
  47.   def disable_item(index)
  48.     draw_item(index, disabled_color)
  49.   end
  50. end
复制代码
试着看看吧....使用方法:比如

你的
@command_window = Window_Command.new(640, [s1, s2, s3, s4, s5, s6])

改为:

@command_window = Window_Command.new(640, [s1, s2, s3, s4, s5, s6], 6)


就是一行显示6个,改为3就是一行3个...




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