Project1

标题: 请教如何将菜单选项分为两排显示? [打印本页]

作者: 文雅夕露    时间: 2018-1-20 00:00
标题: 请教如何将菜单选项分为两排显示?
由于不懂脚本。想请教下前辈们。
我现在修改成的效果为:


现在想修改为如下面排版:


但不知道该如何将菜单选项分为两排显示?
请教一下。顺便问下在脚本如何描绘如上图的菜单选项后的阴影?

附上工程:
Project4.zip (1.15 MB, 下载次数: 94)
作者: king    时间: 2018-1-20 00:10
https://rpg.blue/thread-158548-1-2.html

看看这个就行
改改即可
作者: chd114    时间: 2018-1-20 09:45
首先找到這個菜單窗口的父類,裏面應該有一個設置行數(排數)的參數(默認是1),複製一個進去窗口的腳本,然後把他改成2
也可能你的窗口的腳本裏面已經有指定行數為1了,那直接把那個1改成2
然後把每一排顯示的項目減少到3(也就是col_max,你的這個腳本應該是讓col_max直接返回項目數,搜.size找到然後直接指定3就行)
那麼你應該會得到一個整齊的2排的菜單(每排3項)
作者: king    时间: 2018-1-20 09:49
  1. class String  
  2.   alias old_plus +  
  3.   def +(other)  
  4.     self.old_plus(other.to_s)      
  5.   end   
  6. end


  7. module Cache
  8.   def self.menu(filename)
  9.     load_bitmap("Graphics/Menus/", filename)
  10.   end
  11. end

  12. class Window_Gold_new < Window_Base
  13.   #--------------------------------------------------------------------------
  14.   # * 物件初始化
  15.   #     x : 视窗X座标
  16.   #     y : 视窗Y座标
  17.   #--------------------------------------------------------------------------
  18.   def initialize(x, y)
  19.     super(x-40, y-48, 120, WLH + 32)
  20.     refresh
  21.   end
  22.   #--------------------------------------------------------------------------
  23.   # * 更新内容显示
  24.   #--------------------------------------------------------------------------
  25.   def refresh
  26.     self.contents.clear
  27.     self.opacity = 0
  28.     draw_currency_value($game_party.gold, 4, 0, 80)
  29.   end
  30. end

  31. class Window_Time < Window_Base
  32.   def initialize(x, y)
  33.     super(x+280, y+280, 300, WLH + 64 + 32)
  34.     self.opacity = 0
  35.     refresh
  36.   end
  37.   def refresh
  38.     self.contents.clear
  39.     self.contents.font.color = system_color
  40.     self.contents.draw_text(4+40, 32, 120+200, 32, "遊戲時間:")
  41.     @total_sec = Graphics.frame_count / Graphics.frame_rate
  42.     hour = @total_sec / 60 / 60
  43.     min = @total_sec / 60 % 60
  44.     sec = @total_sec % 60
  45.     text = sprintf("%02d:%02d:%02d", hour, min, sec)
  46.     self.contents.font.color = normal_color
  47.     self.contents.draw_text(16+100, 32, 120+16, 32, text, 1)
  48. end
  49.   def update
  50.     super
  51.     if Graphics.frame_count / Graphics.frame_rate != @total_sec
  52.       refresh
  53.     end
  54.   end
  55. end

  56. class Window_Command_new < Window_Selectable
  57.   #--------------------------------------------------------------------------
  58.   # * 宣告执行个体变数
  59.   #--------------------------------------------------------------------------
  60.   attr_reader   :commands                 # 命令
  61.   #--------------------------------------------------------------------------
  62.   # * 物件初始化
  63.   #     width      : 视窗宽度
  64.   #     commands   : 命令字串(阵列)
  65.   #     column_max : 纵栏数(如果大于等于2则横向分布命令条目)
  66.   #     row_max    : 总横行数(0:与命令条目数匹配)
  67.   #     spacing : 条目水准分布时的间距大小
  68.   #--------------------------------------------------------------------------
  69.   def initialize(width, commands, column_max = 3, row_max = 2, spacing = 12)
  70.     if row_max == 0
  71.       row_max = (commands.size + column_max - 1) / column_max
  72.     end
  73.     super(100, 0, 400, row_max * WLH + 32, spacing)
  74.     @commands = commands
  75.     @item_max = commands.size
  76.     @column_max = column_max
  77.     refresh
  78.     self.index = 0
  79.   end
  80.   #--------------------------------------------------------------------------
  81.   # * 更新内容显示
  82.   #--------------------------------------------------------------------------
  83.   def refresh
  84.     self.contents.clear
  85.     for i in 0...@item_max
  86.       draw_item(i)
  87.     end
  88.   end
  89.   #--------------------------------------------------------------------------
  90.   # * 绘制条目
  91.   #     index   : 条目编号
  92.   #     enabled : 可用性标帜,如果为false则半透明化条目绘制。
  93.   #--------------------------------------------------------------------------
  94.   def draw_item(index, enabled = true)
  95.     rect = item_rect(index)
  96.     rect.x += 4
  97.     rect.width -= 8
  98.     self.contents.clear_rect(rect)
  99.     self.contents.font.color = normal_color
  100.     self.contents.font.color.alpha = enabled ? 255 : 128
  101.     self.contents.draw_text(rect, @commands[index])
  102.   end
  103. end


  104. class Scene_Menu < Scene_Base
  105.   def start
  106.     super
  107.     create_command_window
  108.     @gold_window = Window_Gold_new.new(424, 48)
  109.     @time_window = Window_Time.new(0,36)
  110.     @status_window = Window_MenuStatus.new(0, 140-60)
  111.     @menu_back = Plane.new   
  112.     @menu_back.bitmap = Cache.menu("Background")
  113.   end
  114.   
  115.   def pre_terminate
  116.     @status_window.close
  117.     @time_window.close
  118.     @gold_window.close
  119.     @command_window.close
  120.     begin
  121.     @status_window.update
  122.     @time_window.update
  123.     @gold_window.update
  124.     @command_window.update
  125.     @menu_back.ox += 1
  126.     Graphics.update
  127.     end until @status_window.openness == 0
  128.   end  
  129.   def terminate
  130.     @command_window.dispose
  131.     @gold_window.dispose
  132.     @menu_back.dispose
  133.     @status_window.dispose
  134.     @time_window.dispose
  135.   end
  136.   
  137.   def update
  138.     @menu_back.ox += 1
  139.     @command_window.update
  140.     @gold_window.update
  141.     @status_window.update
  142.     @time_window.update
  143.     if @command_window.active
  144.       update_command_selection
  145.     elsif @status_window.active
  146.       update_actor_selection
  147.     end
  148.   end
  149.   
  150.   #--------------------------------------------------------------------------
  151.   # * 创建命令视窗
  152.   #--------------------------------------------------------------------------
  153.   def create_command_window
  154.     s1 = Vocab::status
  155.     s2 = Vocab::skill
  156.     s3 = Vocab::item
  157.     s4 = Vocab::equip
  158.     s5 = Vocab::save
  159.     s6 = "結束遊戲"
  160.     @command_window = Window_Command_new.new(544, [s1, s2, s3, s4, s5, s6])#, s7
  161.     @command_window.index = @menu_index
  162.     @command_window.x = 0
  163.     if $game_party.members.size == 0          # 如果无人在队
  164.       @command_window.draw_item(0, false)     # 禁用[状态]
  165.       @command_window.draw_item(1, false)     # 禁用[技能]
  166.       @command_window.draw_item(2, false)     # 禁用[用品]
  167.       @command_window.draw_item(3, false)     # 禁用[整备]
  168.     end
  169.     if $game_system.save_disabled             # 如果禁止存档
  170.       @command_window.draw_item(4, false)     # 禁用[存档]
  171.     end
  172.     @command_window.opacity = 0
  173.   end
  174.   
  175.   #--------------------------------------------------------------------------
  176.   # * 更新指令选择输入资讯
  177.   #--------------------------------------------------------------------------
  178.   def update_command_selection
  179.     if Input.trigger?(Input::B)
  180.       Sound.play_cancel
  181.       $scene = Scene_Map.new
  182.     elsif Input.trigger?(Input::C)
  183.       if $game_party.members.size == 0 and @command_window.index < 4
  184.         Sound.play_buzzer
  185.         return
  186.       elsif $game_system.save_disabled and @command_window.index == 4
  187.         Sound.play_buzzer
  188.         return
  189.       end
  190.       Sound.play_decision
  191.       case @command_window.index
  192.       when 2      # 用品
  193.         $scene = Scene_Item.new
  194.       when 0,1,3  # 技能,整备,状态
  195.         start_actor_selection
  196.       when 4      # 存档
  197.         $scene = Scene_File.new(true, false, false)
  198.       when 5      # 结束游戏
  199.         $scene = Scene_End.new
  200.       end
  201.     end
  202.   end
  203.   #--------------------------------------------------------------------------
  204.   # * 开始接收主角选择指令输入资讯
  205.   #--------------------------------------------------------------------------
  206.   def start_actor_selection
  207.     @command_window.active = false
  208.     @status_window.active = true
  209.     if $game_party.last_actor_index < @status_window.item_max
  210.       @status_window.index = $game_party.last_actor_index
  211.     else
  212.       @status_window.index = 0
  213.     end
  214.   end
  215.   #--------------------------------------------------------------------------
  216.   # * 停止接收主角选择指令输入资讯
  217.   #--------------------------------------------------------------------------
  218.   def end_actor_selection
  219.     @command_window.active = true
  220.     @status_window.active = false
  221.     @status_window.index = -1
  222.   end
  223.   #--------------------------------------------------------------------------
  224.   # * 更新主角选择指令输入资讯
  225.   #--------------------------------------------------------------------------
  226.   def update_actor_selection
  227.     if Input.trigger?(Input::B)
  228.       Sound.play_cancel
  229.       end_actor_selection
  230.     elsif Input.trigger?(Input::C)
  231.       $game_party.last_actor_index = @status_window.index
  232.       Sound.play_decision
  233.       case @command_window.index
  234.       when 1  # 技能
  235.         $scene = Scene_Skill.new(@status_window.index)
  236.       when 3  # 整备
  237.         $scene = Scene_Equip.new(@status_window.index)
  238.       when 0  # 状态
  239.         $scene = Scene_Status.new(@status_window.index)
  240.       end
  241.     end
  242.   end
  243. end

  244. class Scene_Item < Scene_Base
  245.   #--------------------------------------------------------------------------
  246.   # * 返回之前的画面
  247.   #--------------------------------------------------------------------------
  248.   def return_scene
  249.     $scene = Scene_Menu.new(2)
  250.   end
  251. end

  252. class Scene_Equip < Scene_Base
  253.   #--------------------------------------------------------------------------
  254.   # * 返回之前的画面
  255.   #--------------------------------------------------------------------------
  256.   def return_scene
  257.     $scene = Scene_Menu.new(3)
  258.   end
  259. end

  260. class Scene_Status < Scene_Base
  261.   #--------------------------------------------------------------------------
  262.   # * 返回之前的画面
  263.   #--------------------------------------------------------------------------
  264.   def return_scene
  265.     $scene = Scene_Menu.new(0)
  266.   end
  267. end

  268. class Window_MenuStatus < Window_Selectable
  269.   #--------------------------------------------------------------------------
  270.   # * 物件初始化
  271.   #     x : 视窗X座标
  272.   #     y : 视窗Y座标
  273.   #--------------------------------------------------------------------------
  274.   def initialize(x, y)
  275.     super(x, y, 544,276)
  276.     refresh
  277.     self.active = false
  278.     self.index = -1
  279.     self.opacity = 1
  280.   end
  281.   #--------------------------------------------------------------------------
  282.   # * 更新内容显示
  283.   #--------------------------------------------------------------------------
  284.   def refresh
  285.     self.contents.clear
  286.     @item_max = $game_party.members.size
  287.     for actor in $game_party.members
  288.       if actor.index < 2
  289.         if actor.index % 2 == 0
  290.           actor_position_x = 0
  291.         else
  292.           actor_position_x = 250
  293.         end
  294.         actor_position_y = 0
  295.       else
  296.         if actor.index % 2 == 0
  297.           actor_position_x = 140
  298.         else
  299.           actor_position_x = 390
  300.         end
  301.         actor_position_y = 110
  302.       end
  303.       draw_halfbody(actor.face_name,actor.face_index,actor_position_x,actor_position_y)
  304.       if actor.index < 2
  305.         if actor.index % 2 == 0
  306.           actor_position_x = 0
  307.         else
  308.           actor_position_x = 250
  309.         end
  310.         actor_position_y = 0
  311.         x = 100 + actor_position_x
  312.         y = actor_position_y + 40 + WLH / 2
  313.       else
  314.         if actor.index % 2 == 0
  315.           actor_position_x = 0
  316.         else
  317.           actor_position_x = 250
  318.         end
  319.         actor_position_y = 100
  320.         x = 20 + actor_position_x
  321.         y = actor_position_y + 45 + WLH / 2
  322.       end
  323.       draw_actor_name(actor, x + 20+40, y - WLH + 5)
  324.   #    draw_actor_level(actor, x+40 , y)
  325.    #   draw_actor_state(actor, x+40, y + WLH * 2)
  326.       draw_actor_hp(actor, x+40, y + WLH * 1+60)
  327.       draw_actor_mp(actor, x+40, y + WLH * 2+60)
  328.     end
  329.   end
  330.   
  331.   def draw_halfbody(half_name,half_index, x, y)
  332.       half_name = half_name + "_" + half_index
  333.       bitmap = Cache.load_bitmap("Graphics/Battlers/", half_name)
  334.       rect = Rect.new(0, 0, 0, 0)
  335.       rect.x = 0
  336.       rect.y = 0
  337.       rect.width = 234
  338.       rect.height = 234
  339.       self.contents.blt(x-32,y,bitmap,rect)
  340.       bitmap.dispose
  341.   end
  342.   
  343.   #--------------------------------------------------------------------------
  344.   # * 更新游标绘制
  345.   #--------------------------------------------------------------------------
  346.   def update_cursor
  347.     if @index < 0               # 无光标
  348.       self.cursor_rect.empty
  349.     elsif @index < @item_max    # 正常状态
  350.       if @index < 2
  351.         if @index % 2 == 0
  352.           actor_position_x = 95+24
  353.         else
  354.           actor_position_x = 345+24
  355.         end
  356.         actor_position_y = 22+WLH/2
  357.         self.cursor_rect.set(actor_position_x-10, actor_position_y, 165, 96)
  358.       else
  359.         if @index % 2 == 0
  360.           actor_position_x = 22+24
  361.         else
  362.           actor_position_x = 272+24
  363.         end
  364.         actor_position_y = 128+WLH/2
  365.         self.cursor_rect.set(actor_position_x-10, actor_position_y, 165, 96)
  366.       end
  367.     elsif @index >= 100         # 使用者自身
  368.       self.cursor_rect.set(0, (@index - 100) * 96, contents.width, 96)
  369.     else                        # 全体队员
  370.       if @item_max < 3
  371.         contents_height = 140
  372.         if @item_max == 1
  373.           contents_width = 177
  374.         else
  375.           contents_width = contents.width
  376.         end
  377.         self.cursor_rect.set(0, 0, contents_width, contents_height )
  378.       else
  379.         contents_height = 244
  380.         self.cursor_rect.set(0, 0, contents.width, contents_height)
  381.       end
  382.     end
  383.   end
  384. end
复制代码

作者: WantMy蕙    时间: 2018-1-20 18:22
其实我很好奇绿色结界后来怎么样了...
你们不是应该有分部门制作然后拼起来的吗...
还是说你是自己一个人独立出来的
【话说最近没怎么看到晨露酱】




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