赞 | 7 |
VIP | 20 |
好人卡 | 0 |
积分 | 16 |
经验 | 11472 |
最后登录 | 2024-7-10 |
在线时间 | 526 小时 |
Lv3.寻梦者 宛若
- 梦石
- 0
- 星屑
- 1583
- 在线时间
- 526 小时
- 注册时间
- 2007-8-19
- 帖子
- 1493
 
|
本帖最后由 逸豫 于 2010-10-22 10:15 编辑
- $选项间距离 = 7
- class Window_Title < Window_Base
- attr :index,true
- def initialize(width, arr)
- @arr = arr
- arr.push("") if arr.empty?
- super(0,0,width,arr.size*32 + $选项间距离+32)
- self.contents = Bitmap.new(width - 32,self.height - 32)
- @index = 0
- refresh
- @cmax = arr.size
- end
- def refresh
- y = 0
- for i in @arr
- self.contents.draw_text(0,y,self.width-32,32,i,1)
- if @arr.index(i) == 0
- y += $选项间距离
- end
- y += 32
- end
- end
- def update
- if Input.repeat?(Input::DOWN) && self.active and @cmax > 0 and @index >= 0
- @index += 1
- @index %= @cmax
- $game_system.se_play($data_system.cursor_se)
- end
- if Input.repeat?(Input::UP) && self.active and @cmax > 0 and @index >= 0
- @index -= 1
- @index = @cmax - 1 if @index == -1
- $game_system.se_play($data_system.cursor_se)
- end
- update_cursor
- end
- def update_cursor
- case @index
- when 0
- self.cursor_rect = Rect.new(0,0,self.width-32,32)
- when 1
- self.cursor_rect = Rect.new(0,32+$选项间距离,self.width-32,32)
- when 2
- self.cursor_rect = Rect.new(0,64+$选项间距离,self.width-32,32)
- end
- end
- #--------------------------------------------------------------------------
- # ● 描绘项目
- # index : 项目编号
- # color : 文字色
- #--------------------------------------------------------------------------
- def draw_item(index, color)
- self.contents.font.color = color
- rect = Rect.new(4, 32 * index, self.contents.width - 8, 32)
- if index > 0
- rect.y += $选项间距离
- end
- self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
- self.contents.draw_text(rect, @arr[index],1)
- end
- #--------------------------------------------------------------------------
- # ● 项目无效化
- # index : 项目编号
- #--------------------------------------------------------------------------
- def disable_item(index)
- draw_item(index, disabled_color)
- end
- end
-
复制代码 自行在Scene_Title中使用,把Window_Command.new换成Window_Title.new |
评分
-
查看全部评分
|