Project1

标题: 向下超过最大值无底线求约束 [打印本页]

作者: 金芒芒    时间: 2023-4-18 17:11
标题: 向下超过最大值无底线求约束
RUBY 代码复制
  1. def update_cursor_rect
  2.     #@back.bitmap = RPG::Cache.menu("item_command"+type.to_s)
  3.     # 光标位置不满 0 的情况下
  4.     if @index < 0
  5.       self.cursor_rect.empty
  6.       return
  7.     end
  8.  
  9.     # 获取当前的行
  10.     row = @index/@column_max
  11.     # 当前行被显示开头行前面的情况下
  12.     if row < self.top_row
  13.       # 从当前行向开头行滚动
  14.       self.top_row = row
  15.     end
  16.     # 当前行被显示末尾行之后的情况下
  17.     if row > self.top_row + (self.page_row_max - 1)
  18.       # 从当前行向末尾滚动
  19.       self.top_row = row - (self.page_row_max - 1)
  20.     end
  21.  
  22.     @right.y = self.y+12+self.top_row.to_f*120.0*(3*120)/(@item_max.to_f*120)
  23.  
  24.     # 计算光标的宽度
  25.     cursor_width = 240
  26.     # 计算光标坐标
  27.     x = @index%4*86+2
  28.     y = @index/4-self.oy/120
  29.     # 更新光标矩形
  30.     self.cursor_rect.set(@index%4*84+2,(@index/4-self.oy/120)*120-1,85,120)
  31.     #self.cursor_rect.set(x, y, 86, 120)
  32.   end
  33. #--------------------------------------------------------------------------
  34.   # ● 刷新画面
  35.   #--------------------------------------------------------------------------
  36.   def update
  37.     super
  38.  
  39.     # 可以移动光标的情况下
  40.     if self.active and @item_max >= 0 and @index >= 0
  41.       # 方向键下被按下的情况下
  42.       if Input.repeat?(Input::LEFT)#DOWN上
  43.         # 光标向下移动
  44.         $game_system.se_play($data_system.cursor_se)
  45.         @index = (@index-1+@item_max) % @item_max if @item_max != 0
  46.         update_help
  47.       end
  48.       # 方向键上被按下的情况下
  49.       if Input.repeat?(Input::RIGHT)#UP下
  50.         # 光标向上移动
  51.         $game_system.se_play($data_system.cursor_se)
  52.         @index = (@index+1+@item_max) % @item_max if @item_max != 0
  53.         update_help
  54.       end
  55.  
  56.       end
  57.     # 可以移动光标的情况下
  58.      if self.active and @item_max > 0 and @item_max <= 40 #and @index >= 0
  59.       # 方向键下被按下的情况下
  60.       if Input.repeat?(Input::DOWN)#DOWN上
  61.         # 光标向下移动
  62.         $game_system.se_play($data_system.cursor_se)
  63.         @index +=4 #(@index+1+@item_max) % @item_max if @item_max != 0
  64.         update_help
  65.       end
  66.     end
  67.       # 方向键上被按下的情况下
  68.       if self.active and @item_max <= 43 and @index<=40#@item_max
  69.       if Input.repeat?(Input::UP)#UP下
  70.         # 光标向上移动
  71.         $game_system.se_play($data_system.cursor_se)
  72.         @index -=4 #(@index-1+@item_max) % @item_max if @item_max != 0
  73.         update_help
  74.       end
  75.  
  76.     end

12人.png (600.71 KB, 下载次数: 3)

12人.png





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