赞 | 0 |
VIP | 46 |
好人卡 | 26 |
积分 | 7 |
经验 | 76056 |
最后登录 | 2024-11-23 |
在线时间 | 2658 小时 |
Lv2.观梦者
- 梦石
- 0
- 星屑
- 653
- 在线时间
- 2658 小时
- 注册时间
- 2010-6-28
- 帖子
- 1361
|
3楼
楼主 |
发表于 2011-7-12 09:00:57
|
只看该作者
as853484572 发表于 2011-7-11 21:24
恩……可不可以给出脚本呢? - #==============================================================================
- # 箭头式Window_Selectable窗体 by 沉影不器
- #------------------------------------------------------------------------------
- # 功能说明: 更改默认Window_Selectable窗体的样式为箭头式
- # 使用说明: ① 复制脚本,插入到Main之前
- # ② 制作箭头的动画文件命名为"cursor_arrow",存放到Graphics\System
- # 目录下,动画格式为纵向顺序动画,帧数不限,大小不限
- # 对动画文件不明白,请参考范例所附的两个动画文件
- # ③ 参数设定在脚本第16行到29行
- # ★其中16行"箭头动画的帧数"为必设项,请务必正确填写
- #==============================================================================
- class Window_Selectable < Window_Base
- #--------------------------------------------------------------------------
- # ○ 参数设定
- #--------------------------------------------------------------------------
- # ★ 箭头动画的帧数(必设项)
- ARROW_FRAME = 3
- # 箭头动画的速度 (取值范围: 1 ~ 游戏最大帧数)
- ANIMATION_SPEED = 50
- # 项目描绘横向缩进(通常为箭头动画宽度的一半)
- INDENT = 12
- # 箭头横向位置微调
- X_ADJ = 2
- # 箭头纵向位置微调
- Y_ADJ = 0
- # 自定义选择框颜色1
- COLOR1 = Color.new(0, 0, 0, 0)
- # 自定义选择框颜色2
- COLOR2 = Color.new(255, 255, 255, 0)
- #--------------------------------------------------------------------------
- # ○ 常量
- #--------------------------------------------------------------------------
- CURSOR_WAIT = 4 # 光标缓冲
- #--------------------------------------------------------------------------
- # ● 初始化对象
- # x : 窗口的 X 坐标
- # y : 窗口的 Y 坐标
- # width : 窗口的宽
- # height : 窗口的高
- # spacing : 与项目横向并立的空间
- #--------------------------------------------------------------------------
- def initialize(x, y, width, height, spacing = 32)
- @item_max = 1
- @column_max = 1
- @index = -1
- @spacing = spacing
- super(x, y, width, height)
- create_cursor_rect
- create_cursor_arrow
- # 动画帧
- @arrow_index = 0
- # 动画频率
- @animation_count = 0
- # 光标缓冲
- @cursor_count = 0
- end
- #--------------------------------------------------------------------------
- # ○ 释放
- #--------------------------------------------------------------------------
- def dispose
- @cursor_rect.dispose
- @cursor_arrow.dispose
- super
- end
- #--------------------------------------------------------------------------
- # ○ 生成光标选区
- #--------------------------------------------------------------------------
- def create_cursor_rect
- @cursor_rect = Sprite.new
- # 隐藏
- @cursor_rect.visible = false
- @cursor_rect.bitmap = Bitmap.new(self.width + 16, self.height)
- end
- #--------------------------------------------------------------------------
- # ○ 生成光标箭头
- #--------------------------------------------------------------------------
- def create_cursor_arrow
- # 预读取
- bitmap = Cache.system("cursor_arrow")
- @arrow_width = bitmap.width
- @arrow_height = bitmap.height / ARROW_FRAME
- bitmap.dispose # 释放
-
- @cursor_arrow = Sprite.new
- # 隐藏
- @cursor_arrow.visible = false
- @cursor_arrow.bitmap = Bitmap.new(@arrow_width, @arrow_height)
- end
- #--------------------------------------------------------------------------
- # ○ 描绘光标
- #--------------------------------------------------------------------------
- def set_cursor_rect(rect)
- # 满宽
- rect.width += 32
- @cursor_rect.bitmap.clear
- @cursor_rect.bitmap.gradient_fill_rect(rect, COLOR1, COLOR2)
- # viewport判断
- unless self.viewport == nil
- @cursor_rect.viewport = self.viewport
- @cursor_arrow.viewport = self.viewport
- end
- # 可视性同步判断
- @cursor_rect.visible = (self.openness == 255 && self.visible)
- @cursor_arrow.visible = (self.openness == 255 && self.visible && self.active)
- # 光标无效时返回
- return unless @cursor_rect.visible
- # 光标跟随选项
- @cursor_rect.x = self.x - 8
- @cursor_rect.y = self.y + 16
- @cursor_rect.z = self.z + 1
- @cursor_arrow.x = @cursor_rect.x + rect.x + X_ADJ
- @cursor_arrow.y = @cursor_rect.y + rect.y + Y_ADJ
- @cursor_arrow.z = @cursor_rect.z + 1
- end
- #--------------------------------------------------------------------------
- # ○ 光标子类 更新箭头
- #--------------------------------------------------------------------------
- def update_cursor_arrow
- # 动画频率计数
- @animation_count += 1
- # 化速度
- if @animation_count > (Graphics.frame_rate - ANIMATION_SPEED)
- @animation_count = 0
- # 动画帧控制
- @arrow_index < (ARROW_FRAME - 1) ? @arrow_index += 1 : @arrow_index = 0
- # 描绘
- bitmap = Cache.system("cursor_arrow")
- rect = Rect.new(0, @arrow_index*@arrow_height, @arrow_width, @arrow_height)
- @cursor_arrow.bitmap.clear
- @cursor_arrow.bitmap.blt(0, 0, bitmap, rect)
- bitmap.dispose # 释放
- end
- end
- #--------------------------------------------------------------------------
- # ● 获取项目要描画的矩形
- # index : 项目编号
- #--------------------------------------------------------------------------
- def item_rect(index)
- rect = Rect.new(0, 0, 0, 0)
- # 预留箭头宽度
- rect.width = (contents.width + @spacing) / @column_max - @spacing - INDENT
- # 窗体边框
- rect.width -= 4
- rect.height = WLH
- # 调整坐标
- rect.x = index % @column_max * (rect.width + @spacing) + INDENT
- # 窗体边框
- rect.x += 4
- rect.y = index / @column_max * WLH
- return rect
- end
- #--------------------------------------------------------------------------
- # ● 更新光标
- #--------------------------------------------------------------------------
- def update_cursor
- if @index < 0 # 光标的位置不满 0 的情况下
- # 光标无效
- @cursor_rect.visible = false
- @cursor_arrow.visible = false
- else # 光标的位置为 0 以上的情况下
- row = @index / @column_max # 获取现在的行数
- if row < top_row # 如果显示的行在最顶行之前
- self.top_row = row # 则将最顶行向现在行滚动
- end
- if row > bottom_row # 如果显示的行在末尾行之后
- self.bottom_row = row # 则将末尾行向现在行滚动
- end
- rect = item_rect(@index) # 获取被选择项目的矩形
- rect.y -= self.oy # 如果矩形与滚动位置重合
- # 光标缓冲
- @cursor_count += 1
- return if @cursor_count < CURSOR_WAIT
- # 更新光标
- set_cursor_rect(rect)
- # 更新箭头
- update_cursor_arrow
- end
- # 清空光标缓冲
- @cursor_count = 0 if @cursor_rect.visible == false
- end
- end
- #==============================================================================
- # ■ Window_Equip
- #------------------------------------------------------------------------------
- # 装备画面、显示角色现在装备的物品的窗口。
- #==============================================================================
- class Window_Equip < Window_Selectable
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- def refresh
- self.contents.clear
- @data = []
- for item in @actor.equips do @data.push(item) end
- @item_max = @data.size
- self.contents.font.color = system_color
- if @actor.two_swords_style
- self.contents.draw_text(INDENT+4, WLH * 0, 92, WLH, Vocab::weapon1)
- self.contents.draw_text(INDENT+4, WLH * 1, 92, WLH, Vocab::weapon2)
- else
- self.contents.draw_text(INDENT+4, WLH * 0, 92, WLH, Vocab::weapon)
- self.contents.draw_text(INDENT+4, WLH * 1, 92, WLH, Vocab::armor1)
- end
- self.contents.draw_text(INDENT+4, WLH * 2, 92, WLH, Vocab::armor2)
- self.contents.draw_text(INDENT+4, WLH * 3, 92, WLH, Vocab::armor3)
- self.contents.draw_text(INDENT+4, WLH * 4, 92, WLH, Vocab::armor4)
- draw_item_name(@data[0], 92, WLH * 0)
- draw_item_name(@data[1], 92, WLH * 1)
- draw_item_name(@data[2], 92, WLH * 2)
- draw_item_name(@data[3], 92, WLH * 3)
- draw_item_name(@data[4], 92, WLH * 4)
- end
- end
- #==============================================================================
- # ■ Window_Message
- #------------------------------------------------------------------------------
- # 显示文章的信息窗口。
- #==============================================================================
- class Window_Message < Window_Selectable
- #--------------------------------------------------------------------------
- # ● 更新光标
- #--------------------------------------------------------------------------
- def update_cursor
- if @index >= 0
- x = $game_message.face_name.empty? ? 0 : 112
- y = ($game_message.choice_start + @index) * WLH
- rect = Rect.new(x + 16, y, contents.width - x - 16, WLH)
- # 更新光标
- set_cursor_rect(rect)
- # 更新箭头
- update_cursor_arrow
- else
- # 光标无效
- @cursor_rect.visible = false
- @cursor_arrow.visible = false
- end
- end
- end
复制代码 |
|