Project1
标题:
图书馆音乐鉴赏无法翻页
[打印本页]
作者:
嚴子
时间:
2013-4-3 19:21
标题:
图书馆音乐鉴赏无法翻页
如下脚本。我想用它做音乐播放,但是它最多只能显示16首歌曲。若放进更多歌曲,可以播放但是无法看到歌曲名以及选项位置。
求解如何实现翻页。
如果实在没办法,能不能实现一页显示35首歌曲。很急。求帮忙
#==============================================================================
# ■ Scene_Read
#==============================================================================
class Scene_Read_SUPER
#--------------------------------------------------------------------------
# ● 主处理
#--------------------------------------------------------------------------
def main
sp = Spriteset_Map.new
@read_window = Window_Reader.new([""], 0)
@read_window.opacity = 230
@read_window.z = 900
@command_window = Window_Command.new(180, ["选音乐","选书阅读"])
@command_window.y = (480 - @command_window.height)/2
@command_window.opacity = 230
@command_window.z = 999
@doing = 0
Graphics.transition
# 主循环
loop do
# 刷新游戏画面
Graphics.update
# 刷新输入信息
Input.update
# 刷新画面
update
# 如果画面切换的话就中断循环
if $scene != self
break
end
end
# 准备过渡
Graphics.freeze
@command_window.dispose if !@command_window.disposed?
@read_window.dispose
sp.dispose
end
def update
case @doing
when 0 #选项
update_0
when 1 #选书
update_1
when 2 #读书
update_2
when 3 #选音乐
update_3
end
end
def update_0
@command_window.update
if Input.trigger?(Input::C)
case @command_window.index
when 0
$game_system.se_play($data_system.decision_se)
text = Dir["Audio/music/*"]
@text = []
for tx in text
@text.push(tx.split(/music\//)[1])
end
@command_window.dispose
@command_window = Window_Command.new(180, @text)
@command_window.y = (480 - @command_window.height)/2
@command_window.opacity = 230
@command_window.z = 999
@doing = 3
when 1
$game_system.se_play($data_system.decision_se)
text = Dir["Graphics/txt/*"]
@text = []
for tx in text
@text.push (tx.split(/txt\//)[1].split(/.txt/)[0])
end
@command_window.dispose
@command_window = Window_Command.new(180, @text)
@command_window.y = (480 - @command_window.height)/2
@command_window.opacity = 230
@command_window.z = 999
@doing = 1
when 2
$game_system.se_play($data_system.decision_se)
@command_window.visible = false
@command_window.active = false
@doing = 2
end
end
if Input.trigger?(Input::B)
$game_system.se_play($data_system.decision_se)
$scene = Scene_Map.new
end
end
def update_1
@command_window.update
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@doing = 0
@command_window.dispose
if @read_window.text != [""]
@command_window = Window_Command.new(180, ["选音乐","选书阅读","继续阅读"])
else
@command_window = Window_Command.new(180, ["选音乐","选书阅读"])
end
@command_window.y = (480 - @command_window.height)/2
@command_window.opacity = 230
@command_window.z = 999
end
if Input.trigger?(Input::C)
$game_system.se_play($data_system.decision_se)
filename = "Graphics/txt/" + @command_window.commands[@command_window.index]+".txt"
file = File.open(filename, "r")
r = file.readlines
@real_text = []
for i in 0...r.size
temp_story = r[i].split(/\n/)[0]
temp_story.gsub!(/,/) {","} if temp_story != nil
temp_story.gsub!(/\./) {"。"} if temp_story != nil
temp_story.gsub!(/ /) {" "} if temp_story != nil
while(temp_story != nil)
text = ""
if temp_story.length > 75
text = temp_story.slice!(0,75)
else
text = temp_story
temp_story = nil
end
@real_text.push(text)
end
end
file.close
@read_window.renew(@real_text, 0)
@command_window.visible = false
@command_window.active = false
@doing = 2
end
end
def update_2
@read_window.update
if Input.trigger?(Input::B)
$game_system.se_play($data_system.decision_se)
@doing = 0
@command_window.dispose
if @read_window.text != [""]
@command_window = Window_Command.new(180, ["选音乐","选书阅读","继续阅读"])
else
@command_window = Window_Command.new(180, ["选音乐","选书阅读"])
end
@command_window.y = (480 - @command_window.height)/2
@command_window.opacity = 230
@command_window.z = 999
@doing = 0
end
if Input.trigger?(Input::UP)
$game_system.se_play($data_system.cursor_se)
@read_window.minus_1
end
if Input.trigger?(Input::DOWN)
$game_system.se_play($data_system.cursor_se)
@read_window.add_1
end
if Input.trigger?(Input::L) or Input.trigger?(Input::LEFT)
$game_system.se_play($data_system.cursor_se)
@read_window.page_back
end
if Input.trigger?(Input::R) or Input.trigger?(Input::RIGHT)
$game_system.se_play($data_system.cursor_se)
@read_window.page_add
end
end
def update_3
@command_window.update
if Input.trigger?(Input::C)
$game_system.se_play($data_system.decision_se)
filename = "Audio/music/" + @command_window.commands[@command_window.index]
Audio.bgm_play(filename, 100, 100)
end
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@doing = 0
@command_window.dispose
if @read_window.text != [""]
@command_window = Window_Command.new(180, ["选音乐","选书阅读","继续阅读"])
else
@command_window = Window_Command.new(180, ["选音乐","选书阅读"])
end
@command_window.y = (480 - @command_window.height)/2
@command_window.opacity = 230
@command_window.z = 999
end
end
end
复制代码
作者:
joe5491
时间:
2013-4-3 23:24
修好了~
#==============================================================================
# ■ Scene_Read
#==============================================================================
class Scene_Read_SUPER
#--------------------------------------------------------------------------
# ● 主处理
#--------------------------------------------------------------------------
def main
sp = Spriteset_Map.new
@read_window = Window_Reader.new([""], 0)
@read_window.opacity = 230
@read_window.z = 900
@command_window = Window_Command.new(180, ["选音乐","选书阅读"])
@command_window.y = (480 - @command_window.height)/2
@command_window.opacity = 230
@command_window.z = 999
@doing = 0
Graphics.transition
# 主循环
loop do
# 刷新游戏画面
Graphics.update
# 刷新输入信息
Input.update
# 刷新画面
update
# 如果画面切换的话就中断循环
if $scene != self
break
end
end
# 准备过渡
Graphics.freeze
@command_window.dispose if !@command_window.disposed?
@read_window.dispose
sp.dispose
end
def update
case @doing
when 0 #选项
update_0
when 1 #选书
update_1
when 2 #读书
update_2
when 3 #选音乐
update_3
end
end
def update_0
@command_window.update
if Input.trigger?(Input::C)
case @command_window.index
when 0
$game_system.se_play($data_system.decision_se)
text = Dir["Audio/music/*"]
@text = []
for tx in text
@text.push(tx.split(/music\//)[1])
end
@command_window.dispose
@command_window = Window_Command.new(180, @text)
@command_window.y = (480 - @command_window.height)/2
if @command_window.y < 0
@command_window.y=0
@command_window.height=480
end
@command_window.opacity = 230
@command_window.z = 999
@doing = 3
when 1
$game_system.se_play($data_system.decision_se)
text = Dir["Graphics/txt/*"]
@text = []
for tx in text
@text.push (tx.split(/txt\//)[1].split(/.txt/)[0])
end
@command_window.dispose
@command_window = Window_Command.new(180, @text)
@command_window.y = (480 - @command_window.height)/2
if @command_window.y < 0
@command_window.y=0
@command_window.height=480
end
@command_window.opacity = 230
@command_window.z = 999
@doing = 1
when 2
$game_system.se_play($data_system.decision_se)
@command_window.visible = false
@command_window.active = false
@doing = 2
end
end
if Input.trigger?(Input::B)
$game_system.se_play($data_system.decision_se)
$scene = Scene_Map.new
end
end
def update_1
@command_window.update
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@doing = 0
@command_window.dispose
if @read_window.text != [""]
@command_window = Window_Command.new(180, ["选音乐","选书阅读","继续阅读"])
else
@command_window = Window_Command.new(180, ["选音乐","选书阅读"])
end
@command_window.y = (480 - @command_window.height)/2
@command_window.opacity = 230
@command_window.z = 999
end
if Input.trigger?(Input::C)
$game_system.se_play($data_system.decision_se)
filename = "Graphics/txt/" + @command_window.commands[@command_window.index]+".txt"
file = File.open(filename, "r")
r = file.readlines
@real_text = []
for i in 0...r.size
temp_story = r[i].split(/\n/)[0]
temp_story.gsub!(/,/) {","} if temp_story != nil
temp_story.gsub!(/\./) {"。"} if temp_story != nil
temp_story.gsub!(/ /) {" "} if temp_story != nil
while(temp_story != nil)
text = ""
if temp_story.length > 75
text = temp_story.slice!(0,75)
else
text = temp_story
temp_story = nil
end
@real_text.push(text)
end
end
file.close
@read_window.renew(@real_text, 0)
@command_window.visible = false
@command_window.active = false
@doing = 2
end
end
def update_2
@read_window.update
if Input.trigger?(Input::B)
$game_system.se_play($data_system.decision_se)
@doing = 0
@command_window.dispose
if @read_window.text != [""]
@command_window = Window_Command.new(180, ["选音乐","选书阅读","继续阅读"])
else
@command_window = Window_Command.new(180, ["选音乐","选书阅读"])
end
@command_window.y = (480 - @command_window.height)/2
@command_window.opacity = 230
@command_window.z = 999
@doing = 0
end
if Input.trigger?(Input::UP)
$game_system.se_play($data_system.cursor_se)
@read_window.minus_1
end
if Input.trigger?(Input::DOWN)
$game_system.se_play($data_system.cursor_se)
@read_window.add_1
end
if Input.trigger?(Input::L) or Input.trigger?(Input::LEFT)
$game_system.se_play($data_system.cursor_se)
@read_window.page_back
end
if Input.trigger?(Input::R) or Input.trigger?(Input::RIGHT)
$game_system.se_play($data_system.cursor_se)
@read_window.page_add
end
end
def update_3
@command_window.update
#if @command_window.index >15
if Input.trigger?(Input::C)
$game_system.se_play($data_system.decision_se)
filename = "Audio/music/" + @command_window.commands[@command_window.index]
Audio.bgm_play(filename, 100, 100)
end
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@doing = 0
@command_window.dispose
if @read_window.text != [""]
@command_window = Window_Command.new(180, ["选音乐","选书阅读","继续阅读"])
else
@command_window = Window_Command.new(180, ["选音乐","选书阅读"])
end
@command_window.y = (480 - @command_window.height)/2
@command_window.opacity = 230
@command_window.z = 999
end
end
end
复制代码
p.s.我不知道實現翻頁是啥意思,因為我沒有Window_Reader的腳本,給出來在幫你吧......
作者:
嚴子
时间:
2013-4-4 18:18
joe5491 发表于 2013-4-3 23:24
修好了~p.s.我不知道實現翻頁是啥意思,因為我沒有Window_Reader的腳本,給出來在幫你吧...... ...
就是这样的效果!谢谢您。认可答案。
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1