赞 | 1 |
VIP | 246 |
好人卡 | 87 |
积分 | 1 |
经验 | 34142 |
最后登录 | 2015-1-15 |
在线时间 | 323 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 55
- 在线时间
- 323 小时
- 注册时间
- 2010-8-21
- 帖子
- 666
|
楼主 |
发表于 2011-4-27 18:17:45
|
显示全部楼层
针对斜着移动优化...:- #==============================================================================
- # ■ Rect
- #------------------------------------------------------------------------------
- # 矩形类
- #==============================================================================
- # 移动帧数,自己改
- Cursor_Rect_Move = 10
- class Rect
- # 设置
- alias old_set set unless Rect.method_defined? "old_set"
- def set(x,y,w,h,de=false)
- if @target_rect.is_a?(Rect)
- return if @target_rect == Rect.new(x,y,w,h) or @target_rect_i == Rect.new(x,y,w,h)
- end
- if de
- if self.x != x and self.y != y
- # 斜着
- @inclined = true
- @cursor_rect_move = Cursor_Rect_Move
- @target_rect_i = Rect.new(x,y,w,h)
- @target_rect = Rect.new(self.x,self.y,0,0)
-
- else
- @inclined = false
- # 横竖
- @cursor_rect_move = Cursor_Rect_Move
- @target_rect = Rect.new(x,y,w,h)
- end
- else
- self.old_set(x,y,w,h)
- end
- end
- # 刷新
- def update
- return unless @target_rect and @cursor_rect_move
- @cursor_rect_move -= 1
- if @cursor_rect_move <= 0 and @inclined
- @cursor_rect_move = Cursor_Rect_Move
- @target_rect = @target_rect_i.dup
- @target_rect_i = nil
- return @inclined = false
- end
- return if @cursor_rect_move <= 0
- x = (@target_rect.x - self.x) / @cursor_rect_move
- y = (@target_rect.y - self.y) / @cursor_rect_move
- w = (@target_rect.width - self.width) / @cursor_rect_move
- h = (@target_rect.height - self.height) / @cursor_rect_move
- self.old_set(x+self.x,y+self.y,w+self.width,h+self.height)
- end
- end
- #==============================================================================
- # ■ Window_Base
- #------------------------------------------------------------------------------
- # 游戏中全部窗口的超级类。
- #==============================================================================
- class Window_Base < Window
- #--------------------------------------------------------------------------
- # ● 刷新画面
- #--------------------------------------------------------------------------
- def update
- super
- self.cursor_rect.update
- # 如果窗口的外关被变更了、再设置
- if $game_system.windowskin_name != @windowskin_name
- @windowskin_name = $game_system.windowskin_name
- self.windowskin = RPG::Cache.windowskin(@windowskin_name)
- end
- end
- end
- #==============================================================================
- # ■ Window_Selectable
- #------------------------------------------------------------------------------
- # 拥有光标的移动以及滚动功能的窗口类。
- #==============================================================================
- class Window_Selectable < Window_Base
- #--------------------------------------------------------------------------
- # ● 更新光标举行
- #--------------------------------------------------------------------------
- def update_cursor_rect
- # 光标位置不满 0 的情况下
- if @index < 0
- self.cursor_rect.empty
- return
- end
- # 获取当前的行
- row = @index / @column_max
- # 当前行被显示开头行前面的情况下
- if row < self.top_row
- # 从当前行向开头行滚动
- self.top_row = row
- end
- # 当前行被显示末尾行之后的情况下
- if row > self.top_row + (self.page_row_max - 1)
- # 从当前行向末尾滚动
- self.top_row = row - (self.page_row_max - 1)
- end
- # 计算光标的宽
- cursor_width = self.width / @column_max - 32
- # 计算光标坐标
- x = @index % @column_max * (cursor_width + 32)
- y = @index / @column_max * 32 - self.oy
- # 更新国标矩形
- self.cursor_rect.set(x, y, cursor_width, 32,true)
- end
- end
- #==============================================================================
- # ■ Window_Message
- #------------------------------------------------------------------------------
- # 显示文章的信息窗口。
- #==============================================================================
- class Window_Message < Window_Selectable
- #--------------------------------------------------------------------------
- # ● 刷新光标矩形
- #--------------------------------------------------------------------------
- def update_cursor_rect
- if @index >= 0
- n = $game_temp.choice_start + @index
- self.cursor_rect.set(8, n * 32, @cursor_width, 32,true)
- else
- self.cursor_rect.empty
- end
- end
- end
复制代码 另:
全局搜索: self.cursor_rect.set(
把最后的 “)" 改为 ",true)" (不含引号) 即加一个参数 true
已经是 ",true)" 的不用修改 |
|