加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
本帖最后由 金芒芒 于 2023-4-11 16:24 编辑
也就是4*3 就翻到下一页 头像大小是66*80
如何让光标走到第4个就往第2行走
class Window_Troops_List< Window_Base def blue_color return Color.new(141,157,180) end #-------------------------------------------------------------------------- # ● 定义实例变量 #-------------------------------------------------------------------------- attr_reader :index # 光标位置 attr_reader :help_window # 帮助窗口 attr_reader :type # 种类 attr_reader :able # 暗色 def type=(type)#类型 @type = type end def type return @type end #-------------------------------------------------------------------------- # ● 设置光标的位置 # index : 新的光标位置 #-------------------------------------------------------------------------- def index=(index)#定义索引=(索引) @index = index#@索引=(索引) # 刷新帮助文本 (update_help 定义了继承目标) #如果是自己。活动和@help窗口!=无 if self.active and @help_window != nil update_help#更新帮助 end # 刷新光标矩形 update_cursor_rect#更新游标矩形 end #-------------------------------------------------------------------------- # ● 获取行数 #-------------------------------------------------------------------------- def row_max #定义行最大值 # 由项目数和列数计算出行数 return @item_max #返回@项目最大值 end #-------------------------------------------------------------------------- # ● 获取开头行 #-------------------------------------------------------------------------- def top_row # 将窗口内容的传送源 Y 坐标、1 行的高 32 等分 return self.oy / 32 end #-------------------------------------------------------------------------- # ● 设置开头行 # row : 显示开头的行 #-------------------------------------------------------------------------- def top_row=(row)#定义首行=(行) # row 未满 0 的场合更正为 0 if row < 0 row = 0 end # row 超过 row_max - 1 的情况下更正为 row_max - 1 if row > row_max - 1 row = row_max - 1 end # row 1 行高的 32 倍、窗口内容的传送源 Y 坐标 self.oy = row * 32 end #-------------------------------------------------------------------------- # ● 获取 1 页可以显示的行数 #-------------------------------------------------------------------------- def page_row_max #@column_max = 2 # 窗口的高度,设置画面的高度减去 32 ,除以 1 行的高度 32 return 14 #头像行数 end
class Window_Troops_List< Window_Base
def blue_color
return Color.new(141,157,180)
end
#--------------------------------------------------------------------------
# ● 定义实例变量
#--------------------------------------------------------------------------
attr_reader :index # 光标位置
attr_reader :help_window # 帮助窗口
attr_reader :type # 种类
attr_reader :able # 暗色
def type=(type)#类型
@type = type
end
def type
return @type
end
#--------------------------------------------------------------------------
# ● 设置光标的位置
# index : 新的光标位置
#--------------------------------------------------------------------------
def index=(index)#定义索引=(索引)
@index = index#@索引=(索引)
# 刷新帮助文本 (update_help 定义了继承目标)
#如果是自己。活动和@help窗口!=无
if self.active and @help_window != nil
update_help#更新帮助
end
# 刷新光标矩形
update_cursor_rect#更新游标矩形
end
#--------------------------------------------------------------------------
# ● 获取行数
#--------------------------------------------------------------------------
def row_max #定义行最大值
# 由项目数和列数计算出行数
return @item_max #返回@项目最大值
end
#--------------------------------------------------------------------------
# ● 获取开头行
#--------------------------------------------------------------------------
def top_row
# 将窗口内容的传送源 Y 坐标、1 行的高 32 等分
return self.oy / 32
end
#--------------------------------------------------------------------------
# ● 设置开头行
# row : 显示开头的行
#--------------------------------------------------------------------------
def top_row=(row)#定义首行=(行)
# row 未满 0 的场合更正为 0
if row < 0
row = 0
end
# row 超过 row_max - 1 的情况下更正为 row_max - 1
if row > row_max - 1
row = row_max - 1
end
# row 1 行高的 32 倍、窗口内容的传送源 Y 坐标
self.oy = row * 32
end
#--------------------------------------------------------------------------
# ● 获取 1 页可以显示的行数
#--------------------------------------------------------------------------
def page_row_max #@column_max = 2
# 窗口的高度,设置画面的高度减去 32 ,除以 1 行的高度 32
return 14 #头像行数
end
也就是4*3 就翻到下一页 头像大小是66*80
如何让光标走到第4个就往第2行走
def update_cursor_rect #@back.bitmap = RPG::Cache.menu("item_command"+type.to_s) # 光标位置不满 0 的情况下 if @index < 0 self.cursor_rect.empty return end # 获取当前的行 column = @index # 当前行被显示开头行前面的情况下 if column < self.top_column # 从当前行向开头行滚动 self.top_column = column end # 当前行被显示末尾行之后的情况下 if column > self.top_column + (self.page_column_max - 1) # 从当前行向末尾滚动 self.top_column = column - (self.page_column_max - 1) end @right.x = self.x+72+self.top_column.to_f*66.0*(4*66)/(@item_max.to_f*66) # 计算光标的宽度 cursor_width = 1200 # 计算光标坐标 x =32+ @index*66 - self.ox-1# 8 # y = 4 #@index*20 - self.oy-1 # 更新光标矩形 self.cursor_rect.set(x, y, 66 ,80) end
def update_cursor_rect
#@back.bitmap = RPG::Cache.menu("item_command"+type.to_s)
# 光标位置不满 0 的情况下
if @index < 0
self.cursor_rect.empty
return
end
# 获取当前的行
column = @index
# 当前行被显示开头行前面的情况下
if column < self.top_column
# 从当前行向开头行滚动
self.top_column = column
end
# 当前行被显示末尾行之后的情况下
if column > self.top_column + (self.page_column_max - 1)
# 从当前行向末尾滚动
self.top_column = column - (self.page_column_max - 1)
end
@right.x = self.x+72+self.top_column.to_f*66.0*(4*66)/(@item_max.to_f*66)
# 计算光标的宽度
cursor_width = 1200
# 计算光标坐标
x =32+ @index*66 - self.ox-1# 8 #
y = 4 #@index*20 - self.oy-1
# 更新光标矩形
self.cursor_rect.set(x, y, 66 ,80)
end
|