设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 2489|回复: 2
打印 上一主题 下一主题

[已经解决] 如何让横向排列的多个选择项可以循环

[复制链接]

Lv1.梦旅人

梦石
0
星屑
152
在线时间
78 小时
注册时间
2012-8-16
帖子
44
跳转到指定楼层
1
发表于 2017-6-26 07:41:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
就是光标停留在最后一个选择项时再按右键可以回到第一个选择项

Lv2.观梦者

梦石
0
星屑
433
在线时间
122 小时
注册时间
2010-9-27
帖子
22

开拓者

2
发表于 2017-6-26 15:03:38 | 只看该作者
本帖最后由 酋长的图腾 于 2017-6-26 15:37 编辑

将下面脚本插入Main之前、Window_Selectable之后即可。
RUBY 代码复制
  1. #==============================================================================
  2. # ■ Window_Selectable
  3. #------------------------------------------------------------------------------
  4. #  拥有光标的移动以及滚动功能的窗口类。
  5. #==============================================================================
  6.  
  7. class Window_Selectable < Window_Base
  8.   #--------------------------------------------------------------------------
  9.   # ● 刷新画面
  10.   #--------------------------------------------------------------------------
  11.   def update
  12.     super
  13.     # 可以移动光标的情况下
  14.     if self.active and @item_max > 0 and @index >= 0
  15.       # 方向键下被按下的情况下
  16.       if Input.repeat?(Input::DOWN)
  17.         # 列数不是 1 并且方向键的下的按下状态不是重复的情况、
  18.         # 或光标位置在(项目数-列数)之前的情况下
  19.         if (@column_max == 1 and Input.trigger?(Input::DOWN)) or
  20.            @index < @item_max - @column_max
  21.           # 光标向下移动
  22.           $game_system.se_play($data_system.cursor_se)
  23.           @index = (@index + @column_max) % @item_max
  24.         end
  25.       end
  26.       # 方向键上被按下的情况下
  27.       if Input.repeat?(Input::UP)
  28.         # 列数不是 1 并且方向键的下的按下状态不是重复的情况、
  29.         # 或光标位置在列之后的情况下
  30.         if (@column_max == 1 and Input.trigger?(Input::UP)) or
  31.            @index >= @column_max
  32.           # 光标向上移动
  33.           $game_system.se_play($data_system.cursor_se)
  34.           @index = (@index - @column_max + @item_max) % @item_max
  35.         end
  36.       end
  37.       # 方向键右被按下的情况下
  38.       if Input.repeat?(Input::RIGHT)
  39.         # 列数为 2 以上并且、光标位置在(项目数 - 1)之前的情况下
  40.         if @column_max >= 2 and @index < @item_max - 1
  41.           # 光标向右移动
  42.           $game_system.se_play($data_system.cursor_se)
  43.           @index += 1
  44.         #===================
  45.         elsif @column_max >= 2 and @index + 1 == @item_max
  46.           @index = 0
  47.         end
  48.         #===================
  49.       end
  50.       # 方向键左被按下的情况下
  51.       if Input.repeat?(Input::LEFT)
  52.         # 列数为 2 以上并且、光标位置在 0 之后的情况下
  53.         if @column_max >= 2 and @index > 0
  54.           # 光标向左移动
  55.           $game_system.se_play($data_system.cursor_se)
  56.           @index -= 1
  57.         end
  58.       end
  59.       # R 键被按下的情况下
  60.       if Input.repeat?(Input::R)
  61.         # 显示的最后行在数据中最后行上方的情况下
  62.         if self.top_row + (self.page_row_max - 1) < (self.row_max - 1)
  63.           # 光标向后移动一页
  64.           $game_system.se_play($data_system.cursor_se)
  65.           @index = [@index + self.page_item_max, @item_max - 1].min
  66.           self.top_row += self.page_row_max
  67.         end
  68.       end
  69.       # L 键被按下的情况下
  70.       if Input.repeat?(Input::L)
  71.         # 显示的开头行在位置 0 之后的情况下
  72.         if self.top_row > 0
  73.           # 光标向前移动一页
  74.           $game_system.se_play($data_system.cursor_se)
  75.           @index = [@index - self.page_item_max, 0].max
  76.           self.top_row -= self.page_row_max
  77.         end
  78.       end
  79.     end
  80.     # 刷新帮助文本 (update_help 定义了继承目标)
  81.     if self.active and @help_window != nil
  82.       update_help
  83.     end
  84.     # 刷新光标矩形
  85.     update_cursor_rect
  86.   end
  87. end

点评

感谢!有这个作参考的话各个方向上的都能做出来了  发表于 2017-6-27 06:47

评分

参与人数 1星屑 +150 收起 理由
RyanBern + 150 认可答案

查看全部评分

回复 支持 1 反对 0

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-9-21 21:52

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表