| 
 
| 赞 | 5 |  
| VIP | 464 |  
| 好人卡 | 4 |  
| 积分 | 5 |  
| 经验 | 14189 |  
| 最后登录 | 2020-6-13 |  
| 在线时间 | 972 小时 |  
 Lv2.观梦者 
	梦石0 星屑473 在线时间972 小时注册时间2007-12-31帖子2137 | 
| 
 
 以下为66的MTV系统
 
 发布页:http://rpg.blue/htm/Topic_6764.htm
 范例在中间……
 
 
 BTW:LZ你这是一贴多发
 
 
 
 功能:
 就是播BGM的时候,可以顺便播放.lrc的歌词。当然不一定是.lrc的,.txt也可以。不过文件内容的格式必须是:
 
 [时间1][时间2]歌词
 
 比如:
 
 [01:52.81][00:18.40]多少恋情回想时只剩结局和起头
 
 在网上流行的歌词制作软件,常常制做出各不相同的lrc歌词格式(比如有的中括号时间只精确到秒,或者分钟和秒写在一起等),本脚本只支持此一种,其它的请自己用记事本打开修改为这样的。
 
 要求:
 
 [分钟:秒.小数2位]歌词
 也就是中括号内总共有8个字节。
 
 本效果歌词在战斗中不会停止。如果需要停止,则把Scene_Battle部分删了即可。同时就算切出游戏也不会打乱歌词。
使用:
 1、读取:MTV.load("歌词文件名",总秒数*10)
 如:MTV.load("爱不留歌词.lrc",2870)
 其中总秒数*10表示一首歌结束,歌词开始循环的时间。如果不填这一项则歌词只显示1遍。而爱不留这首歌长度是287秒,输入2870则可以不断循环
 
 2、播放BGM
 
 3、MTV.mtv_begin,开始显示歌词
 
 停止:MTV.stop,关掉歌词。BGM用事件关就行了
 范例下载
 密码:lrcmtv
 
 全脚本
 复制代码#=================================================================
# MTV 脚本,by 66RPG_柳柳
#=================================================================
module MTV  
 #===============================================================
 # 读取文件。文件相对地址:Audio/BGM
 # file_name:文件名;length:MTV长度,按照.1秒为单位记数
 #===============================================================
 def self.load(file_name,length = 0)
   $mtv_time = []
   $mtv_text = []
   $game_system.mtv_length = length
   #=============================================================
   # 打开文件并且读取之
   #=============================================================
   file =  File.open("Audio/BGM/"+file_name)
   #=============================================================
   # 读取歌词
   #=============================================================
   for line in file.readlines
     #===========================================================
     # 转为UTF-8编码
     #===========================================================
     line = EasyConv.s2u(line)
     #===========================================================
     # 寻找本行歌词
     #===========================================================
     this_line_text = line[line.scan(/\]/).size*10,line.size]
     #===========================================================
     # 把读取的行分存成时间与文字
     #===========================================================
     for i in 0...line.scan(/\]/).size
       temp_b = line[i*10+1,8]
       temp_c = temp_b.split(/:/)[0]
       mmsecond = 600 * temp_c.to_i
       temp_c = temp_b.split(/:/)[1]
       mmsecond += 10 * temp_c.to_f
       $mtv_time.push(mmsecond.to_i)
       $mtv_text.push(this_line_text)
     end
   end
   file.close
 end 
 #===============================================================
 # 开始MTV字幕
 #===============================================================
 def self.mtv_begin
   $game_system.mtv_now = true
   $game_system.mtv_begin_time = $sys_timer.now()
   $lrc_text = ""
   return
 end
 #===============================================================
 # 结束MTV字幕
 #===============================================================
 def self.stop
   $game_system.mtv_now = false
   return
 end
 #===============================================================
 # 测试MTV是否播放
 #===============================================================
 def self.mtv?
   return $game_system.mtv_now
 end
 #===============================================================
 # 获取MTV字幕
 #===============================================================
 def self.new_text
   if $game_system.mtv_now
     #===========================================================
     # 求出已经经过的时间
     #===========================================================
     nt = $sys_timer.now()
     nt -= $game_system.mtv_begin_time
     nt = nt.to_i
     nt /= 100      
     #===========================================================
     # 制作循环
     #===========================================================
     if $game_system.mtv_length>0 and nt > $game_system.mtv_length
       nt -= $game_system.mtv_length
     end
     #===========================================================
     # 放出字幕
     #===========================================================
     for tm in 0...$mtv_time.size
       if $mtv_time[tm] == nt
         $lrc_text = $mtv_text[tm]
         break
       end
     end
   else
     $lrc_text = ""
   end
 end
end
#==============================================================================
# 本脚本来自www.66RPG.com,使用和转载请保留此信息
#============================================================================== 
# ------------------------------------------------------------------------
# 高精度计时器 by FantasyDR
# ------------------------------------------------------------------------
# E-mail: [email protected]
# ------------------------------------------------------------------------
# 2005.10.18
# ------------------------------------------------------------------------
# 该类已经被定义为全局变量 $sys_timer
# 如果只需要精确到毫秒,请设置初始化参数为true
# decimal属性设置返回时间值的小数位数。
# ------------------------------------------------------------------------
# 下面是一些有用的方法列表,调用时写:$sys_timer.方法名
# 例如 $sys_timer.clear()
# ------------------------------------------------------------------------
# clear() :计时器清零
# now() :获取当前经过的时间,单位毫秒
# now_s() :获取当前经过的时间,单位秒
# ------------------------------------------------------------------------
class SystemTimer
attr_accessor:decimal #小数位数设定,默认为3
def initialize(use_GetTime=false)
# 初始化,根据系统选择不同精度计时器
@qpFrequency = Win32API.new("kernel32","QueryPerformanceFrequency",'p','L')
@qpCounter = Win32API.new("kernel32","QueryPerformanceCounter",'p','L')
@tGetTime = Win32API.new("winmm","timeGetTime",'','L')
@decimal=3
@perf_cnt=" " * 8
@time_start=" " * 8
@time_now=" " * 8
result = @qpFrequency.call(@perf_cnt)
if use_GetTime
result = 0
end
if result!=0
@perf_flag=true
else
@perf_flag=false
@perf_cnt=[1000,0].pack('LL')
end
#设置时间比例因数
@time_scale=@perf_cnt.unpack('LL')
@time_scale[0] /= 1000.0
@time_scale[1] /= 1000.0
#起始时间清零
self.clear()
end
#-=====================-#
# 计时器清零
#-=====================-#
def clear()
if @perf_flag
@qpCounter.call(@time_start)
else
@time_start=[@tGetTime.call(),0].pack('LL')
end
end
#-==============================-#
# 获取当前经过的时间,单位毫秒
#-==============================-#
def now()
now_time = 0.0e1
now_time += self.timer() - self.start()
now_time /= self.scale()
return self.debug(now_time)
end
#-==============================-#
# 获取当前经过的时间,单位秒
#-==============================-#
def now_s()
now_time = 0.0e1
now_time += self.timer() - self.start()
now_time /= (self.scale()*1000) 
return self.debug(now_time)
end
#-==============================-#
# 帧错...
#-==============================-#
def debug(now_time)
if @decimal>0
now_time = (now_time * (10**@decimal)).floor/(10.0**@decimal)
else
now_time = now_time.floor
end
return now_time
#以下用于debug模式
if now_time < 0
p "Timer Wrong!! Clear...",now_time,\
@perf_flag,@qpCounter,@tGetTime,
@time_now.unpack('LL')[0],@time_now.unpack('LL')[1],
@time_start.unpack('LL')[0],@time_start.unpack('LL')[1]
self.clear()
return 0.0
else
return now_time
end
end
#-=====================-#
# 获取时间比例因数
#-=====================-#
def scale()
return @time_scale[0]+\
@time_scale[1]*0xffffffff
end
#-=====================-#
# 获取起始滴答数
#-=====================-#
def start()
return @time_start.unpack('LL')[0]+\
@time_start.unpack('LL')[1]*0xffffffff
end
#-=====================-#
# 获取当前的嘀哒数
#-=====================-#
def timer()
if @perf_flag
@qpCounter.call(@time_now)
else
@time_now=[@tGetTime.call(),0].pack('LL')
end
return @time_now.unpack('LL')[0]+\
@time_now.unpack('LL')[1]*0xffffffff
end
end
#-------------------------------------#
# 初始化自身成一个全局变量
#-------------------------------------#
$sys_timer=SystemTimer.new()
#-------------------------------------#
#==============================================================================
# 本脚本来自www.66RPG.com,使用和转载请保留此信息
#==============================================================================
#==============================================================================
# 仭 EasyConv module - Ver 0.90
#------------------------------------------------------------------------------
# Moonlight INN
# http://cgi.members.interq.or.jp/aquarius/rasetsu/
# RaTTiE
# [email protected]
#------------------------------------------------------------
# EasyConv::s2u(text) : S-JIS -> UTF-8
# EasyConv::u2s(text) : UTF-8 -> S-JIS
#==============================================================================
module EasyConv
# API梡掕悢掕媊
  CP_ACP = 0
  CP_UTF8 = 65001
#--------------------------------------------------------------------------
# 仠 S-JIS -> UTF-8
#--------------------------------------------------------------------------
def s2u(text)
# API掕媊
  m2w = Win32API.new('kernel32', 'MultiByteToWideChar', 'ilpipi', 'i')
  w2m = Win32API.new('kernel32', 'WideCharToMultiByte', 'ilpipipp', 'i')
# S-JIS -> Unicode
  len = m2w.call(CP_ACP, 0, text, -1, nil, 0);
  buf = "\0" * (len*2)
  m2w.call(CP_ACP, 0, text, -1, buf, buf.size/2);
# Unicode -> UTF-8
  len = w2m.call(CP_UTF8, 0, buf, -1, nil, 0, nil, nil);
  ret = "\0" * len
  w2m.call(CP_UTF8, 0, buf, -1, ret, ret.size, nil, nil);
  
  return ret
end
# module_function偲偟偰岞奐
module_function :s2u
#--------------------------------------------------------------------------
# 仠 UTF-8 -> S-JIS
#--------------------------------------------------------------------------
def u2s(text)
# API掕媊
  m2w = Win32API.new('kernel32', 'MultiByteToWideChar', 'ilpipi', 'i')
  w2m = Win32API.new('kernel32', 'WideCharToMultiByte', 'ilpipipp', 'i')
# UTF-8 -> Unicode
  len = m2w.call(CP_UTF8, 0, text, -1, nil, 0);
  buf = "\0" * (len*2)
  m2w.call(CP_UTF8, 0, text, -1, buf, buf.size/2);
# Unicode -> S-JIS
  len = w2m.call(CP_ACP, 0, buf, -1, nil, 0, nil, nil);
  ret = "\0" * len
  w2m.call(CP_ACP, 0, buf, -1, ret, ret.size, nil, nil);
  
  return ret
end
# module_function偲偟偰岞奐
module_function :u2s
end
#==============================================================================
# ■ Game_System
#------------------------------------------------------------------------------
#  处理系统附属数据的类。也可执行诸如 BGM 管理之类的功能。本类的实例请参考
# $game_system 。
#==============================================================================
class Game_System
 #--------------------------------------------------------------------------
 # ● 定义实例变量
 #--------------------------------------------------------------------------
 attr_accessor :mtv_begin_time
 attr_accessor :mtv_now
 attr_accessor :mtv_length
 #--------------------------------------------------------------------------
 # ● 初始化对像
 #--------------------------------------------------------------------------
 alias mtv_gamesystem_initialize initialize
 def initialize
   mtv_gamesystem_initialize
   @mtv_begin_time = $sys_timer.now()
   @mtv_now = false
   @mtv_length = 0
 end
end  
#==============================================================================
# ■ Scene_Map
#------------------------------------------------------------------------------
#  处理地图画面的类。
#==============================================================================
class Scene_Map
 #--------------------------------------------------------------------------
 # ● 刷新画面
 #-------------------------------------------------------------------------- 
 alias mtv_scenemap_update update
 def update
   @mtv_window.refresh
   mtv_scenemap_update
 end
 #--------------------------------------------------------------------------
 # ● 主处理
 #--------------------------------------------------------------------------
 alias mtv_scenemap_main main
 def main
   @mtv_window = Window_MTV.new
   mtv_scenemap_main
   @mtv_window.dispose
 end
 #--------------------------------------------------------------------------
 # ● 调用战斗 (调整自动切换BGM)
 #--------------------------------------------------------------------------
 def call_battle
   # 清除战斗调用标志
   $game_temp.battle_calling = false
   # 清除菜单调用标志
   $game_temp.menu_calling = false
   $game_temp.menu_beep = false
   # 生成遇敌计数
   $game_player.make_encounter_count
   # 记忆地图 BGM 、停止 BGM
   $game_temp.map_bgm = $game_system.playing_bgm
   unless MTV.mtv?      
     $game_system.bgm_play($game_system.battle_bgm)
     # 演奏战斗开始 SE
     $game_system.se_play($data_system.battle_start_se)
   end
   # 矫正主角姿势
   $game_player.straighten
   # 切换到战斗画面
   $scene = Scene_Battle.new
 end
end
#==============================================================================
# ■ Scene_Battle
#------------------------------------------------------------------------------
#  处理战斗的类。
#==============================================================================
class Scene_Battle
 #--------------------------------------------------------------------------
 # ● 刷新画面
 #-------------------------------------------------------------------------- 
 alias mtv_scenebattle_update update
 def update
   @mtv_window.refresh
   mtv_scenebattle_update
 end
 #--------------------------------------------------------------------------
 # ● 主处理
 #--------------------------------------------------------------------------
 alias mtv_scenebattle_main main
 def main
   @mtv_window = Window_MTV.new
   mtv_scenebattle_main
   @mtv_window.dispose
 end
end
#==============================================================================
# ■ Window_MTV
#------------------------------------------------------------------------------
#  显示MTV字幕的窗口。
#==============================================================================
class Window_MTV < Window_Base
 #--------------------------------------------------------------------------
 # ● 初始化窗口
 #--------------------------------------------------------------------------
 def initialize
   super(0, 416, 640, 64)
   self.contents = Bitmap.new(width - 32, height - 32)
   $lrc_text = ""
   self.z = 9999
   refresh
 end
 #--------------------------------------------------------------------------
 # ● 刷新
 #--------------------------------------------------------------------------
 def refresh(text = "")
   MTV.new_text
   self.contents.clear   
   if $game_temp.in_battle 
     self.opacity = 120
   else
     self.opacity = 0
   end
   self.contents.font.color = Color.new(0,0,0,255)
   self.contents.draw_text(0, 0, 608, 32, $lrc_text, 1)    
   self.contents.font.color = Color.new(255,255,255,255)
   self.contents.draw_text(1, 1, 608, 32, $lrc_text, 1)    
 end
end
 | 
 评分
查看全部评分
 |