| 赞 | 0 |
| VIP | |
| 好人卡 | |
| 积分 | 6 |
| 经验 | |
| 最后登录 | 2023-6-16 |
| 在线时间 | 156 小时 |
秀才
- 梦石
- 0
- 星屑
- 587
- 在线时间
- 156 小时
- 注册时间
- 2008-7-23
- 回帖
- 233

|
悬赏100星屑已解决
[pre lang="ruby"]#-------------------------------------------------------------------------------
# ·(改)图书馆 By 退屈£无聊
#-------------------------------------------------------------------------------
# 呃。无聊写个东西玩先。 Update V1.02
# 介绍说明。音乐的设置格式 @music* = [名称,文件名, 简介],注意文字要加引号!
# 加了歌的话,在调用choose_music也要注意了。
# 相信也应该制作完成了吧。没有BUG了吧-0-。
$是否退出关闭音乐 = true
#-------------------------------------------------------------------------------
class Scene_Dictionary
#===================================================
# ·主过程
#===================================================
def main
@music1 = ["鸦片", " ", "又叫阿片,俗称大烟,源于罂粟植物蒴果,属毒品。17世纪末到18世纪中叶,由于英国在同中国的贸易中长期出于入超地位,因此英国学生会默许了不法商贩走私鸦片到中国的行为。鸦片不但造成了中国大量的白银外流,而且摧残了中国人民的身体和意志。"]
@music2 = ["虎门销烟", " ", "1839年6月,中国清朝学生会委任钦差大臣林则徐在广东虎门集中销毁鸦片的历史事件。此事后来成为第一次鸦片战争的导火线。1839年6月3日(清宣宗道光十九年岁次己亥四月廿二),林则徐下令在虎门海滩当众销毁鸦片,至6月25日结束,共历时23天,销毁鸦片19187箱和2119袋,总重量2376254斤。虎门销烟成为打击毒品的历史事件,维护了中华民族的尊严和利益。"]
@music3 = ["测试", "", ""]
@music4 = ["测试", "", ""]
@music5 = ["测试", "", ""]
@music6 = ["测试", "", ""]
@music7 = ["测试", "", ""]
@music8 = ["测试", "", ""]
@music9 = ["测试", "", ""]
@music10 = ["测试", "", ""]
@music11 = ["测试", "", ""]
@music12 = ["测试", "", ""]
@music13 = ["测试", "", ""]
@music14 = ["测试", "", ""]
@music15 = ["测试", "", ""]
@music16 = ["测试", "", ""]
@music_command = Window_Command.new(200, [@music1[0], @music2[0], @music3[0], @music4[0], @music5[0], @music6[0], @music7[0], @music8[0], @music9[0], @music10[0], @music11[0], @music12[0], @music13[0], @music14[0], @music15[0], @music16[0]])
@music_command.x = 0
@music_command.y = 0
@music_command.opacity = 150
@music_command.z = 9999
@help_window = Window_DictionaryHelp.new
@help_window.x = 200
@help_window.y = 0
@help_window.width = 440
@help_window.height = 480
@help_window.opacity = 150
@help_window.z = 9999
# 执行过渡
Graphics.transition
# 主循环
loop do
# 刷新游戏画面
Graphics.update
# 刷新输入信息
Input.update
# 刷新画面
choose_music([@music1,@music2,@music3,@music4,@music5,@music6,@music7,@music8, @music9,@music10,@music11,@music12,@music13,@music14,@music15,@music16]) # 音乐如果有填加,不要忘了在这里填加!
# 如果画面被切换的话就中断循环
if $scene != self
break
end
end
# 准备过渡
Graphics.freeze
# 释放窗口
@music_command.dispose
@help_window.dispose
end
#==========================================================================
# ·选歌过程
#==========================================================================
def choose_music(music)
@music_command.update
@help_window.update
@musicfile = music
if Input.trigger?(Input::B)
$scene = Scene_Map.new
if $是否退出关闭音乐
$game_map.autoplay
end
end
@help_window.draw_music("#{@musicfile[@music_command.index][2]}")
end
#===========================透明部分==================================
module XRXS_MP7_Module
def create_spriteset
@spriteset = Spriteset_Map.new
end
def dispose_spriteset
@spriteset.dispose
end
end
include XRXS_MP7_Module
alias xrxs_mp7_main main
def main
create_spriteset
xrxs_mp7_main
dispose_spriteset
end
#=========不需要的删到这里为止======================
end
#==============================================================================
# ■ Window_Music
#------------------------------------------------------------------------------
# 音乐简介显示窗口。
#==============================================================================
class Window_DictionaryHelp < Window_Base
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize
super(240, 0, 400, 480)
self.contents = Bitmap.new(self.width - 32, self.height - 32)
end
#--------------------------------------------------------------------------
# ● 描绘音乐
#--------------------------------------------------------------------------
def draw_music(music)
self.contents.clear
# 记录文字x坐标
x = 0
# 记录文字y坐标
y = 0
# 记录换行时y坐标最小加值
min_y = 0
self.contents.font.color = normal_color
# 描绘音乐简介
text = music
# 限制文字处理
begin
last_text = text.clone
text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
end until text == last_text
text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
$game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
end
# c 获取 1 个字 (如果不能取得文字就循环)
while ((c = text.slice!(/./m)) != nil)
# 另起一行文字的情况下
if c == "\n"
y += [32, min_y].max
min_y = 0
x = 0
# 下面的文字
next
end
# 自动换行处理
if x + self.contents.text_size(c).width > self.contents.width
y += [32, min_y].max
min_y = 0
x = 0
end
# 描绘文字
self.contents.draw_text(4 + x, y, 40, 32, c)
# x 为要描绘文字的加法运算
x += self.contents.text_size(c).width
end
end
end[/pre]
这本来是个音乐播放脚本,被改成了类似百科查阅一类的脚本,但是当词条数量太多(超过16个)以后,屏幕上便会溢出而不能正常显示,请问如何给它添加一个向下自动翻页的功能? |
最佳答案
查看完整内容
见下方脚本。
原先是根据 Window_Command 生成列表的,这个类是用于生成命令窗口,不适合做成带翻页的列表窗口。
要实现翻页功能必须自己写一个类似 Window_Item 的窗口。
顺便修了一下右侧说明窗口反复刷新导致 FPS 骤降的问题。
用法有变化,根据已经有的代码进行仿写即可。
[pre lang="ruby"]#-------------------------------------------------------------------------------
# ·(改)图书馆 By 退屈£无聊
#-------- ...
|