| 赞 | 0 |
| VIP | |
| 好人卡 | |
| 积分 | 1 |
| 经验 | |
| 最后登录 | 2016-1-18 |
| 在线时间 | 72 小时 |
- 梦石
- 0
- 星屑
- 55
- 在线时间
- 72 小时
- 注册时间
- 2008-10-27
- 回帖
- 47
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有账号?注册会员
×
本帖最后由 IRO 于 2014-6-26 13:31 编辑
我修改了RGSS里的Window_NameInput,想改成只有26个字母
但是光标上下移动的时后变得不正常......希望有高人能教我该怎么改OTZ
[pre lang="ruby" line="1"]#==============================================================================
# ■ Window_NameInput
#------------------------------------------------------------------------------
# 輸入名稱的畫面、文字選擇視窗。
#==============================================================================
class Window_NameInput < Window_Base
CHARACTER_TABLE =
[
"A","B","C","D","E",
"F","G","H","I","J",
"K","L","M","N","O",
"P","Q","R","S","T",
"U","V","W","X","Y",
"Z",
]
#--------------------------------------------------------------------------
# ● 初始化物件
#--------------------------------------------------------------------------
def initialize
super(340, 160, 180, 260)
self.contents = Bitmap.new(width - 32, height - 32)
@index = 0
refresh
update_cursor_rect
end
#--------------------------------------------------------------------------
# ● 獲取文字
#--------------------------------------------------------------------------
def character
return CHARACTER_TABLE[@index]
end
#--------------------------------------------------------------------------
# ● 更新
#--------------------------------------------------------------------------
def refresh
self.contents.clear
for i in 0..25
x = 1 + i / 5 / 6 * 152 + i % 5 * 28
y = i / 5 % 6 * 32
self.contents.draw_text(x, y, 28, 32, CHARACTER_TABLE, 1)
end
self.contents.draw_text(80, 6 * 32, 64, 32, "Finish", 1)
end
#--------------------------------------------------------------------------
# ● 更新游標矩形
#--------------------------------------------------------------------------
def update_cursor_rect
# 游標位置在 [確定] 的情況下
if @index >= 26
self.cursor_rect.set(80, 9 * 32, 64, 32)
# 游標位置在 [確定] 以外的情況下
else
x = 1 + @index / 5 / 9 * 152 + @index % 5 * 28
y = @index / 5 % 9 * 32
self.cursor_rect.set(x, y, 28, 32)
end
end
#--------------------------------------------------------------------------
# ● 更新畫面
#--------------------------------------------------------------------------
def update
super
# 游標位置在 [確定] 的情況下
if @index >= 180
# 游標下
if Input.trigger?(Input::DOWN)
$game_system.se_play($data_system.cursor_se)
@index -= 180
end
# 游標上
if Input.repeat?(Input::UP)
$game_system.se_play($data_system.cursor_se)
@index -= 180 - 40
end
# 游標位置在 [確定] 以外的情況下
else
# 按下方向鍵右的情況下
if Input.repeat?(Input::RIGHT)
# 按下狀態不是重複的情況下、
# 游標位置不在右端的情況下
if Input.trigger?(Input::RIGHT) or
@index / 30 < 3 or @index % 5 < 4
# 游標向右移動
$game_system.se_play($data_system.cursor_se)
if @index % 5 < 4
@index += 1
else
@index += 30 - 4
end
if @index >= 180
@index -= 180
end
end
end
# 按下方向鍵左的情況下
if Input.repeat?(Input::LEFT)
# 按下狀態不是重複的情況下、
# 游標位置不在左端的情況下
if Input.trigger?(Input::LEFT) or
@index / 30 > 0 or @index % 5 > 0
# 游標向右移動
$game_system.se_play($data_system.cursor_se)
if @index % 5 > 0
@index -= 1
else
@index -= 30 - 4
end
if @index < 0
@index += 180
end
end
end
# 按下方向鍵下的情況下
if Input.repeat?(Input::DOWN)
# 游標向下移動
$game_system.se_play($data_system.cursor_se)
if @index % 30 < 25
@index += 5
else
@index += 180 - 40
end
end
# 按下方向鍵上的情況下
if Input.repeat?(Input::UP)
# 按下狀態不是重複的情況下、
# 游標位置不在上端的情況下
if Input.trigger?(Input::UP) or @index % 30 >= 5
# 游標向上移動
$game_system.se_play($data_system.cursor_se)
if @index % 30 >= 5
@index -= 5
else
@index += 180
end
end
end
# L 鍵與 R 鍵被按下的情況下
if Input.repeat?(Input::L) or Input.repeat?(Input::R)
# 平假名 / 片假名 之間移動
$game_system.se_play($data_system.cursor_se)
if @index / 30 < 2
@index += 90
else
@index -= 90
end
end
end
update_cursor_rect
end
end[/pre]
|
|