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

Project1

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

动态选项光标

 关闭 [复制链接]

Lv1.梦旅人

不画画就死星人

梦石
0
星屑
171
在线时间
1819 小时
注册时间
2007-6-14
帖子
3220
跳转到指定楼层
1
发表于 2007-12-29 03:44:39 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
不好意思了...今天问题很多
脚本是这样的


  1. #==============================================================================
  2. # ■ Window_Selectable
  3. #------------------------------------------------------------------------------
  4. #  拥有光标的移动以及滚动功能的窗口类。
  5. #==============================================================================

  6. class Window_Selectable < Window_Base
  7.   #--------------------------------------------------------------------------
  8.   # ● 定义实例变量
  9.   #--------------------------------------------------------------------------
  10.   attr_reader   :index                    # 光标位置
  11.   attr_reader   :help_window              # 帮助窗口
  12.   #--------------------------------------------------------------------------
  13.   # ● 初始画对像
  14.   #     x      : 窗口的 X 坐标
  15.   #     y      : 窗口的 Y 坐标
  16.   #     width  : 窗口的宽
  17.   #     height : 窗口的高
  18.   #--------------------------------------------------------------------------
  19.   def initialize(x, y, width, height)
  20.     super(x, y, width, height)
  21.     @item_max = 1
  22.     @column_max = 1
  23.     @index = -1
  24.     @x=0
  25.     @y=0
  26.   end
  27.   #--------------------------------------------------------------------------
  28.   # ● 设置光标的位置
  29.   #     index : 新的光标位置
  30.   #--------------------------------------------------------------------------
  31.   def index=(index)
  32.     @index = index
  33.     # 刷新帮助文本 (update_help 定义了继承目标)
  34.     if self.active and @help_window != nil
  35.       update_help
  36.     end
  37.     # 刷新光标矩形
  38.     update_cursor_rect
  39.   end
  40.   #--------------------------------------------------------------------------
  41.   # ● 获取行数
  42.   #--------------------------------------------------------------------------
  43.   def row_max
  44.     # 由项目数和列数计算出行数
  45.     return (@item_max + @column_max - 1) / @column_max
  46.   end
  47.   #--------------------------------------------------------------------------
  48.   # ● 获取开头行
  49.   #--------------------------------------------------------------------------
  50.   def top_row
  51.     # 将窗口内容的传送源 Y 坐标、1 行的高 32 等分
  52.     return self.oy / 32
  53.   end
  54.   #--------------------------------------------------------------------------
  55.   # ● 设置开头行
  56.   #     row : 显示开头的行
  57.   #--------------------------------------------------------------------------
  58.   def top_row=(row)
  59.     # row 未满 0 的场合更正为 0
  60.     if row < 0
  61.       row = 0
  62.     end
  63.     # row 超过 row_max - 1 的情况下更正为 row_max - 1
  64.     if row > row_max - 1
  65.       row = row_max - 1
  66.     end
  67.     # row 1 行高的 32 倍、窗口内容的传送源 Y 坐标
  68.     self.oy = row * 32
  69.   end
  70.   #--------------------------------------------------------------------------
  71.   # ● 获取 1 页可以显示的行数
  72.   #--------------------------------------------------------------------------
  73.   def page_row_max
  74.     # 窗口的高度,设置画面的高度减去 32 ,除以 1 行的高度 32
  75.     return (self.height - 32) / 32
  76.   end
  77.   #--------------------------------------------------------------------------
  78.   # ● 获取 1 页可以显示的项目数
  79.   #--------------------------------------------------------------------------
  80.   def page_item_max
  81.     # 将行数 page_row_max 乘上列数 @column_max
  82.     return page_row_max * @column_max
  83.   end
  84.   #--------------------------------------------------------------------------
  85.   # ● 帮助窗口的设置
  86.   #     help_window : 新的帮助窗口
  87.   #--------------------------------------------------------------------------
  88.   def help_window=(help_window)
  89.     @help_window = help_window
  90.     # 刷新帮助文本 (update_help 定义了继承目标)
  91.     if self.active and @help_window != nil
  92.       update_help
  93.     end
  94.   end
  95.   #--------------------------------------------------------------------------
  96.   # ● 更新光标举行
  97.   #--------------------------------------------------------------------------
  98.   def update_cursor_rect
  99.     # 光标位置不满 0 的情况下
  100.     if @index < 0
  101.       self.cursor_rect.empty
  102.       return
  103.     end
  104.     # 获取当前的行
  105.     row = @index / @column_max
  106.     # 当前行被显示开头行前面的情况下
  107.     if row < self.top_row
  108.       # 从当前行向开头行滚动
  109.       self.top_row = row
  110.     end
  111.     # 当前行被显示末尾行之后的情况下
  112.     if row > self.top_row + (self.page_row_max - 1)
  113.       # 从当前行向末尾滚动
  114.       self.top_row = row - (self.page_row_max - 1)
  115.     end
  116.     # 计算光标的宽
  117.     cursor_width = self.width / @column_max - 32
  118.     # 计算光标坐标
  119.     #x = @index % @column_max * (cursor_width + 32)
  120.     #y = @index / @column_max * 32 - self.oy
  121.     @x = move(@x,@index % @column_max * (cursor_width + 32.5),5)
  122.     @y = move(@y,@index / @column_max * 32.5 - self.oy,5)
  123.     self.cursor_rect.set(@x, @y, cursor_width, 32)
  124.   end
  125.   #--------------------------------------------------------------------------
  126.   # ● 刷新画面
  127.   #--------------------------------------------------------------------------
  128.   def update
  129.     super
  130.     # 可以移动光标的情况下
  131.     if self.active and @item_max > 0 and @index >= 0
  132.       # 方向键下被按下的情况下
  133.       if Input.repeat?(Input::DOWN)
  134.         # 列数不是 1 并且方向键的下的按下状态不是重复的情况、
  135.         # 或光标位置在(项目数-列数)之前的情况下
  136.         if (@column_max == 1 and Input.trigger?(Input::DOWN)) or
  137.            @index < @item_max - @column_max
  138.           # 光标向下移动
  139.           $game_system.se_play($data_system.cursor_se)
  140.           @index = (@index + @column_max) % @item_max
  141.         end
  142.       end
  143.       # 方向键上被按下的情况下
  144.       if Input.repeat?(Input::UP)
  145.         # 列数不是 1 并且方向键的下的按下状态不是重复的情况、
  146.         # 或光标位置在列之后的情况下
  147.         if (@column_max == 1 and Input.trigger?(Input::UP)) or
  148.            @index >= @column_max
  149.           # 光标向上移动
  150.           $game_system.se_play($data_system.cursor_se)
  151.           @index = (@index - @column_max + @item_max) % @item_max
  152.         end
  153.       end
  154.       # 方向键右被按下的情况下
  155.       if Input.repeat?(Input::RIGHT)
  156.         # 列数为 2 以上并且、光标位置在(项目数 - 1)之前的情况下
  157.         if @column_max >= 2 and @index < @item_max - 1
  158.           # 光标向右移动
  159.           $game_system.se_play($data_system.cursor_se)
  160.           @index += 1
  161.         end
  162.       end
  163.       # 方向键左被按下的情况下
  164.       if Input.repeat?(Input::LEFT)
  165.         # 列数为 2 以上并且、光标位置在 0 之后的情况下
  166.         if @column_max >= 2 and @index > 0
  167.           # 光标向左移动
  168.           $game_system.se_play($data_system.cursor_se)
  169.           @index -= 1
  170.         end
  171.       end
  172.       # R 键被按下的情况下
  173.       if Input.repeat?(Input::R)
  174.         # 显示的最后行在数据中最后行上方的情况下
  175.         if self.top_row + (self.page_row_max - 1) < (self.row_max - 1)
  176.           # 光标向后移动一页
  177.           $game_system.se_play($data_system.cursor_se)
  178.           @index = [@index + self.page_item_max, @item_max - 1].min
  179.           self.top_row += self.page_row_max
  180.         end
  181.       end
  182.       # L 键被按下的情况下
  183.       if Input.repeat?(Input::L)
  184.         # 显示的开头行在位置 0 之后的情况下
  185.         if self.top_row > 0
  186.           # 光标向前移动一页
  187.           $game_system.se_play($data_system.cursor_se)
  188.           @index = [@index - self.page_item_max, 0].max
  189.           self.top_row -= self.page_row_max
  190.         end
  191.       end
  192.     end
  193.     # 刷新帮助文本 (update_help 定义了继承目标)
  194.     if self.active and @help_window != nil
  195.       update_help
  196.     end
  197.     # 刷新光标矩形
  198.     update_cursor_rect
  199.   end
  200.   def move(play,target_play,time)
  201.     t = time
  202.     play = (play * (t - 1) + target_play) / t
  203.     time -=1
  204.     return play
  205.   end
  206. end
复制代码

用了发现它对选择项(就是事件页那个)不起作用,我想让它把选择项的光标也变动态,请问如何修改..之前问过类似的,但是那些帖子不见了,我脚本又不知道整理到哪去了,所以无奈来求助...
渣绘关注慎重
[url=http://www.pixiv.net/member.php?id=1160389][color=DimGray]http://www.pixiv.net/member.php?id=1160389[/color][/url]

Lv1.梦旅人

不画画就死星人

梦石
0
星屑
171
在线时间
1819 小时
注册时间
2007-6-14
帖子
3220
2
 楼主| 发表于 2007-12-29 03:44:39 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
不好意思了...今天问题很多
脚本是这样的


  1. #==============================================================================
  2. # ■ Window_Selectable
  3. #------------------------------------------------------------------------------
  4. #  拥有光标的移动以及滚动功能的窗口类。
  5. #==============================================================================

  6. class Window_Selectable < Window_Base
  7.   #--------------------------------------------------------------------------
  8.   # ● 定义实例变量
  9.   #--------------------------------------------------------------------------
  10.   attr_reader   :index                    # 光标位置
  11.   attr_reader   :help_window              # 帮助窗口
  12.   #--------------------------------------------------------------------------
  13.   # ● 初始画对像
  14.   #     x      : 窗口的 X 坐标
  15.   #     y      : 窗口的 Y 坐标
  16.   #     width  : 窗口的宽
  17.   #     height : 窗口的高
  18.   #--------------------------------------------------------------------------
  19.   def initialize(x, y, width, height)
  20.     super(x, y, width, height)
  21.     @item_max = 1
  22.     @column_max = 1
  23.     @index = -1
  24.     @x=0
  25.     @y=0
  26.   end
  27.   #--------------------------------------------------------------------------
  28.   # ● 设置光标的位置
  29.   #     index : 新的光标位置
  30.   #--------------------------------------------------------------------------
  31.   def index=(index)
  32.     @index = index
  33.     # 刷新帮助文本 (update_help 定义了继承目标)
  34.     if self.active and @help_window != nil
  35.       update_help
  36.     end
  37.     # 刷新光标矩形
  38.     update_cursor_rect
  39.   end
  40.   #--------------------------------------------------------------------------
  41.   # ● 获取行数
  42.   #--------------------------------------------------------------------------
  43.   def row_max
  44.     # 由项目数和列数计算出行数
  45.     return (@item_max + @column_max - 1) / @column_max
  46.   end
  47.   #--------------------------------------------------------------------------
  48.   # ● 获取开头行
  49.   #--------------------------------------------------------------------------
  50.   def top_row
  51.     # 将窗口内容的传送源 Y 坐标、1 行的高 32 等分
  52.     return self.oy / 32
  53.   end
  54.   #--------------------------------------------------------------------------
  55.   # ● 设置开头行
  56.   #     row : 显示开头的行
  57.   #--------------------------------------------------------------------------
  58.   def top_row=(row)
  59.     # row 未满 0 的场合更正为 0
  60.     if row < 0
  61.       row = 0
  62.     end
  63.     # row 超过 row_max - 1 的情况下更正为 row_max - 1
  64.     if row > row_max - 1
  65.       row = row_max - 1
  66.     end
  67.     # row 1 行高的 32 倍、窗口内容的传送源 Y 坐标
  68.     self.oy = row * 32
  69.   end
  70.   #--------------------------------------------------------------------------
  71.   # ● 获取 1 页可以显示的行数
  72.   #--------------------------------------------------------------------------
  73.   def page_row_max
  74.     # 窗口的高度,设置画面的高度减去 32 ,除以 1 行的高度 32
  75.     return (self.height - 32) / 32
  76.   end
  77.   #--------------------------------------------------------------------------
  78.   # ● 获取 1 页可以显示的项目数
  79.   #--------------------------------------------------------------------------
  80.   def page_item_max
  81.     # 将行数 page_row_max 乘上列数 @column_max
  82.     return page_row_max * @column_max
  83.   end
  84.   #--------------------------------------------------------------------------
  85.   # ● 帮助窗口的设置
  86.   #     help_window : 新的帮助窗口
  87.   #--------------------------------------------------------------------------
  88.   def help_window=(help_window)
  89.     @help_window = help_window
  90.     # 刷新帮助文本 (update_help 定义了继承目标)
  91.     if self.active and @help_window != nil
  92.       update_help
  93.     end
  94.   end
  95.   #--------------------------------------------------------------------------
  96.   # ● 更新光标举行
  97.   #--------------------------------------------------------------------------
  98.   def update_cursor_rect
  99.     # 光标位置不满 0 的情况下
  100.     if @index < 0
  101.       self.cursor_rect.empty
  102.       return
  103.     end
  104.     # 获取当前的行
  105.     row = @index / @column_max
  106.     # 当前行被显示开头行前面的情况下
  107.     if row < self.top_row
  108.       # 从当前行向开头行滚动
  109.       self.top_row = row
  110.     end
  111.     # 当前行被显示末尾行之后的情况下
  112.     if row > self.top_row + (self.page_row_max - 1)
  113.       # 从当前行向末尾滚动
  114.       self.top_row = row - (self.page_row_max - 1)
  115.     end
  116.     # 计算光标的宽
  117.     cursor_width = self.width / @column_max - 32
  118.     # 计算光标坐标
  119.     #x = @index % @column_max * (cursor_width + 32)
  120.     #y = @index / @column_max * 32 - self.oy
  121.     @x = move(@x,@index % @column_max * (cursor_width + 32.5),5)
  122.     @y = move(@y,@index / @column_max * 32.5 - self.oy,5)
  123.     self.cursor_rect.set(@x, @y, cursor_width, 32)
  124.   end
  125.   #--------------------------------------------------------------------------
  126.   # ● 刷新画面
  127.   #--------------------------------------------------------------------------
  128.   def update
  129.     super
  130.     # 可以移动光标的情况下
  131.     if self.active and @item_max > 0 and @index >= 0
  132.       # 方向键下被按下的情况下
  133.       if Input.repeat?(Input::DOWN)
  134.         # 列数不是 1 并且方向键的下的按下状态不是重复的情况、
  135.         # 或光标位置在(项目数-列数)之前的情况下
  136.         if (@column_max == 1 and Input.trigger?(Input::DOWN)) or
  137.            @index < @item_max - @column_max
  138.           # 光标向下移动
  139.           $game_system.se_play($data_system.cursor_se)
  140.           @index = (@index + @column_max) % @item_max
  141.         end
  142.       end
  143.       # 方向键上被按下的情况下
  144.       if Input.repeat?(Input::UP)
  145.         # 列数不是 1 并且方向键的下的按下状态不是重复的情况、
  146.         # 或光标位置在列之后的情况下
  147.         if (@column_max == 1 and Input.trigger?(Input::UP)) or
  148.            @index >= @column_max
  149.           # 光标向上移动
  150.           $game_system.se_play($data_system.cursor_se)
  151.           @index = (@index - @column_max + @item_max) % @item_max
  152.         end
  153.       end
  154.       # 方向键右被按下的情况下
  155.       if Input.repeat?(Input::RIGHT)
  156.         # 列数为 2 以上并且、光标位置在(项目数 - 1)之前的情况下
  157.         if @column_max >= 2 and @index < @item_max - 1
  158.           # 光标向右移动
  159.           $game_system.se_play($data_system.cursor_se)
  160.           @index += 1
  161.         end
  162.       end
  163.       # 方向键左被按下的情况下
  164.       if Input.repeat?(Input::LEFT)
  165.         # 列数为 2 以上并且、光标位置在 0 之后的情况下
  166.         if @column_max >= 2 and @index > 0
  167.           # 光标向左移动
  168.           $game_system.se_play($data_system.cursor_se)
  169.           @index -= 1
  170.         end
  171.       end
  172.       # R 键被按下的情况下
  173.       if Input.repeat?(Input::R)
  174.         # 显示的最后行在数据中最后行上方的情况下
  175.         if self.top_row + (self.page_row_max - 1) < (self.row_max - 1)
  176.           # 光标向后移动一页
  177.           $game_system.se_play($data_system.cursor_se)
  178.           @index = [@index + self.page_item_max, @item_max - 1].min
  179.           self.top_row += self.page_row_max
  180.         end
  181.       end
  182.       # L 键被按下的情况下
  183.       if Input.repeat?(Input::L)
  184.         # 显示的开头行在位置 0 之后的情况下
  185.         if self.top_row > 0
  186.           # 光标向前移动一页
  187.           $game_system.se_play($data_system.cursor_se)
  188.           @index = [@index - self.page_item_max, 0].max
  189.           self.top_row -= self.page_row_max
  190.         end
  191.       end
  192.     end
  193.     # 刷新帮助文本 (update_help 定义了继承目标)
  194.     if self.active and @help_window != nil
  195.       update_help
  196.     end
  197.     # 刷新光标矩形
  198.     update_cursor_rect
  199.   end
  200.   def move(play,target_play,time)
  201.     t = time
  202.     play = (play * (t - 1) + target_play) / t
  203.     time -=1
  204.     return play
  205.   end
  206. end
复制代码

用了发现它对选择项(就是事件页那个)不起作用,我想让它把选择项的光标也变动态,请问如何修改..之前问过类似的,但是那些帖子不见了,我脚本又不知道整理到哪去了,所以无奈来求助...
渣绘关注慎重
[url=http://www.pixiv.net/member.php?id=1160389][color=DimGray]http://www.pixiv.net/member.php?id=1160389[/color][/url]

Lv1.梦旅人

不画画就死星人

梦石
0
星屑
171
在线时间
1819 小时
注册时间
2007-6-14
帖子
3220
3
 楼主| 发表于 2008-1-6 17:44:32 | 只看该作者
一星期了。。。顶一下
渣绘关注慎重
[url=http://www.pixiv.net/member.php?id=1160389][color=DimGray]http://www.pixiv.net/member.php?id=1160389[/color][/url]
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-6-19 02:37

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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