Project1

标题: 请高手帮忙看看这段代码有没有错误!!! [打印本页]

作者: 狼人弟弟    时间: 2016-2-23 19:44
标题: 请高手帮忙看看这段代码有没有错误!!!

事情是这样的,本人刚刚接触VX ace没多久,现在正在研究这款软件,然后我在无意中看到了一段代码,于是就复制起来打算自己用,
但是...
(如下图1)原来在添加到五个人的时候向下选会自动翻页,在用下面这段代码之后,却发现怎么也无法显示那第五个角色了(下图2)!
图1:


图2:


所以前来寻找高手解一下疑惑!还请各位高手帮帮忙~~~小弟在此多谢了{:2_273:}



  #--------------------------------------------------------------------------
  # ● 定义光标矩形  造成无法移动画面,待解决
  #--------------------------------------------------------------------------
  def update_cursor
    if @index < 0
    self.cursor_rect.empty
  else
      self.cursor_rect.set((1 - @index % 1 ) * 84 , @index * 98, 335, 97)
    end
  end
end
作者: 喵呜喵5    时间: 2016-2-23 20:05
本帖最后由 喵呜喵5 于 2016-2-23 20:07 编辑

头像好奶

参考默认的 update_cursor 方法
  1.   def update_cursor
  2.     if @cursor_all
  3.       cursor_rect.set(0, 0, contents.width, row_max * item_height)
  4.       self.top_row = 0
  5.     elsif @index < 0
  6.       cursor_rect.empty
  7.     else
  8.       ensure_cursor_visible
  9.       cursor_rect.set(item_rect(@index))
  10.     end
  11.   end
复制代码
顾名思义, ensure_cursor_visible 的作用就是保证光标移出画面后页面能够自动向上移动
所以你的代码改成这样:
  1.   def update_cursor
  2.     if @index < 0
  3.       self.cursor_rect.empty
  4.     else
  5.       ensure_cursor_visible
  6.       self.cursor_rect.set((1 - @index % 1 ) * 84 , @index * 98, 335, 97)
  7.     end
  8.   end
复制代码

作者: 狼人弟弟    时间: 2016-2-23 20:14
喵呜喵5 发表于 2016-2-23 20:05
头像好奶

参考默认的 update_cursor 方法顾名思义, ensure_cursor_visible 的作用就是保证光标移 ...

真的是非常感谢!!!万分感谢~~~{:2_268:}
作者: 狼人弟弟    时间: 2016-2-24 16:59
喵呜喵5 发表于 2016-2-23 20:05
头像好奶

参考默认的 update_cursor 方法顾名思义, ensure_cursor_visible 的作用就是保证光标移 ...

还有个问题想请问一下,这个update_cursor 究竟在哪个地方?我找了很久也找不到啊~~




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