设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 2730|回复: 6
打印 上一主题 下一主题

[已经解决] 定制RMXP1.03版的歌词字幕系统

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
420 小时
注册时间
2011-3-13
帖子
251
跳转到指定楼层
1
发表于 2012-7-20 14:11:31 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
5星屑
具体功能要求:

1.播放的字幕可以设定移动方向与速度,字幕有纵版和横版。字幕可以修改字体大小、颜色

2.播放字幕的时候可以播放音乐

3.可以插入背景图片,且背景图片可以轮播替换。

4.播放歌词字幕的时候,角色可以自由移动。(有点类似于电影,一边放插曲,一边剧情还在发展)


我的QQ704562646


(RMB不是问题,感激不尽...)

最佳答案

查看完整内容

试试看很古老的MTV脚本呢?我把颜色、字体、字号都提取出来了,方便你使用 范例工程传送门:http://115.com/file/bea82rxm 顺便提供以下我古老游戏的范例工程,不过纵排显示没有做,其实也很好实现,最后有整个脚本的draw方法,自己单独写一个drawR来实现纵排就可以了 1.没有实现速度功能,可以抄抄看window_message是如何实现文字播放速度的,都是很简单的几行代码, 2. 脚本:MTV.load("歌词.lrc") 演奏BGM:童话 脚本:MTV.mt ...

点评

加上一点 窗口最小化时 BGM暂停 否则你的音字就不同步了  发表于 2012-7-22 14:18

Lv1.梦旅人

昨日的黄昏

梦石
0
星屑
106
在线时间
936 小时
注册时间
2006-11-5
帖子
4128

第2届短篇游戏比赛季军第3届短篇游戏大赛小游戏及其他组季军

2
发表于 2012-7-20 14:11:32 | 只看该作者
试试看很古老的MTV脚本呢?我把颜色、字体、字号都提取出来了,方便你使用

范例工程传送门:http://115.com/file/bea82rxm
顺便提供以下我古老游戏的范例工程,不过纵排显示没有做,其实也很好实现,最后有整个脚本的draw方法,自己单独写一个drawR来实现纵排就可以了
1.没有实现速度功能,可以抄抄看window_message是如何实现文字播放速度的,都是很简单的几行代码,

2.
脚本:MTV.load("歌词.lrc")
演奏BGM:童话
脚本:MTV.mtv_begin
注意:必须是LRC格式

3.使用事件的图片功能就可以实现,参考我的范例工程

4.参考范例工程
  1. #设置文字颜色
  2. FONT_COLOR = Color.new(0,0,0,255) #这里指定RGB颜色
  3. FONT_SIZE = 17  #这个是字体的大小
  4. FONT_NAME = "黑体"

  5. #==============================================
  6. # 增加两个用来进行条件判断的临时变量
  7. #==============================================
  8. class Game_Temp
  9.    attr_accessor :old_text
  10.    attr_accessor :refresh_times
  11. alias meanfree_initialize initialize
  12.   def initialize
  13.     meanfree_initialize
  14.     @old_text = ""
  15.     @refresh_times = 0
  16.   end
  17. end

  18. module MTV  
  19. #===============================================================
  20. # 读取文件。文件相对地址:Audio/BGM
  21. # file_name:文件名;length:MTV长度,按照.1秒为单位记数
  22. #===============================================================
  23. def self.load(file_name,length = 0)
  24.   $mtv_time = []
  25.   $mtv_text = []
  26.   $game_system.mtv_length = length
  27.   #=============================================================
  28.   # 打开文件并且读取之
  29.   #=============================================================
  30.   file =  File.open("Audio/BGM/"+file_name)
  31.   #=============================================================
  32.   # 读取歌词
  33.   #=============================================================
  34.   for line in file.readlines
  35.     #===========================================================
  36.     # 转为UTF-8编码
  37.     #===========================================================
  38.     line = EasyConv.s2u(line)
  39.     #===========================================================
  40.     # 寻找本行歌词
  41.     #===========================================================
  42.     this_line_text = line[line.scan(/\]/).size*10,line.size]
  43.     #===========================================================
  44.     # 把读取的行分存成时间与文字
  45.     #===========================================================
  46.     for i in 0...line.scan(/\]/).size
  47.       temp_b = line[i*10+1,8]
  48.       temp_c = temp_b.split(/:/)[0]
  49.       mmsecond = 600 * temp_c.to_i
  50.       temp_c = temp_b.split(/:/)[1]
  51.       mmsecond += 10 * temp_c.to_f
  52.       $mtv_time.push(mmsecond.to_i)
  53.       $mtv_text.push(this_line_text)
  54.     end
  55.   end
  56.   file.close
  57. end
  58. #===============================================================
  59. # 开始MTV字幕
  60. #===============================================================
  61. def self.mtv_begin
  62.   $game_system.mtv_now = true
  63.   $game_system.mtv_begin_time = $sys_timer.now()
  64.   $lrc_text = ""
  65.   return
  66. end
  67. #===============================================================
  68. # 结束MTV字幕
  69. #===============================================================
  70. def self.stop
  71.   $game_system.mtv_now = false
  72.   return
  73. end
  74. #===============================================================
  75. # 测试MTV是否播放
  76. #===============================================================
  77. def self.mtv?
  78.   return $game_system.mtv_now
  79. end
  80. #===============================================================
  81. # 获取MTV字幕
  82. #===============================================================
  83. def self.new_text
  84.   if $game_system.mtv_now
  85.     #===========================================================
  86.     # 求出已经经过的时间
  87.     #===========================================================
  88.     nt = $sys_timer.now()
  89.     nt -= $game_system.mtv_begin_time
  90.     nt = nt.to_i
  91.     nt /= 100      
  92.     #===========================================================
  93.     # 制作循环
  94.     #===========================================================
  95.     if $game_system.mtv_length>0 and nt > $game_system.mtv_length
  96.       nt -= $game_system.mtv_length
  97.     end
  98.     #===========================================================
  99.     # 放出字幕
  100.     #===========================================================
  101.     for tm in 0...$mtv_time.size
  102.       if $mtv_time[tm] == nt
  103.         $lrc_text = $mtv_text[tm]
  104.         #=======================================
  105.         # 时间有限
  106.         $game_temp.old_text = $lrc_text
  107.         $game_temp.refresh_times += 1
  108.         # 面粉无敌
  109.         #=======================================
  110.         break
  111.       end
  112.     end
  113.   else
  114.     $lrc_text = ""
  115.   end
  116. end
  117. end
  118. # ------------------------------------------------------------------------
  119. # 高精度计时器 by FantasyDR
  120. # ------------------------------------------------------------------------
  121. # E-mail: [email protected]
  122. # ------------------------------------------------------------------------
  123. # 2005.10.18
  124. # ------------------------------------------------------------------------
  125. # 该类已经被定义为全局变量 $sys_timer
  126. # 如果只需要精确到毫秒,请设置初始化参数为true
  127. # decimal属性设置返回时间值的小数位数。
  128. # ------------------------------------------------------------------------
  129. # 下面是一些有用的方法列表,调用时写:$sys_timer.方法名
  130. # 例如 $sys_timer.clear()
  131. # ------------------------------------------------------------------------
  132. # clear() :计时器清零
  133. # now() :获取当前经过的时间,单位毫秒
  134. # now_s() :获取当前经过的时间,单位秒
  135. # ------------------------------------------------------------------------
  136. class SystemTimer
  137. attr_accessor:decimal #小数位数设定,默认为3

  138. def initialize(use_GetTime=false)
  139. # 初始化,根据系统选择不同精度计时器
  140. @qpFrequency = Win32API.new("kernel32","QueryPerformanceFrequency",'p','L')
  141. @qpCounter = Win32API.new("kernel32","QueryPerformanceCounter",'p','L')
  142. @tGetTime = Win32API.new("winmm","timeGetTime",'','L')

  143. @decimal=3
  144. @perf_cnt=" " * 8
  145. @time_start=" " * 8
  146. @time_now=" " * 8

  147. result = @qpFrequency.call(@perf_cnt)

  148. if use_GetTime
  149. result = 0
  150. end

  151. if result!=0
  152. @perf_flag=true
  153. else
  154. @perf_flag=false
  155. @perf_cnt=[1000,0].pack('LL')
  156. end

  157. #设置时间比例因数
  158. @time_scale=@perf_cnt.unpack('LL')
  159. @time_scale[0] /= 1000.0
  160. @time_scale[1] /= 1000.0

  161. #起始时间清零
  162. self.clear()
  163. end

  164. #-=====================-#
  165. # 计时器清零
  166. #-=====================-#
  167. def clear()
  168. if @perf_flag
  169. @qpCounter.call(@time_start)
  170. else
  171. @time_start=[@tGetTime.call(),0].pack('LL')
  172. end
  173. end

  174. #-==============================-#
  175. # 获取当前经过的时间,单位毫秒
  176. #-==============================-#
  177. def now()
  178. now_time = 0.0e1
  179. now_time += self.timer() - self.start()
  180. now_time /= self.scale()
  181. return self.debug(now_time)
  182. end

  183. #-==============================-#
  184. # 获取当前经过的时间,单位秒
  185. #-==============================-#
  186. def now_s()
  187. now_time = 0.0e1
  188. now_time += self.timer() - self.start()
  189. now_time /= (self.scale()*1000)
  190. return self.debug(now_time)
  191. end

  192. #-==============================-#
  193. # 帧错...
  194. #-==============================-#
  195. def debug(now_time)
  196. if @decimal>0
  197. now_time = (now_time * (10**@decimal)).floor/(10.0**@decimal)
  198. else
  199. now_time = now_time.floor
  200. end
  201. return now_time

  202. #以下用于debug模式
  203. if now_time < 0
  204. p "Timer Wrong!! Clear...",now_time,\
  205. @perf_flag,@qpCounter,@tGetTime,
  206. @time_now.unpack('LL')[0],@time_now.unpack('LL')[1],
  207. @time_start.unpack('LL')[0],@time_start.unpack('LL')[1]
  208. self.clear()
  209. return 0.0
  210. else
  211. return now_time
  212. end
  213. end

  214. #-=====================-#
  215. # 获取时间比例因数
  216. #-=====================-#
  217. def scale()
  218. return @time_scale[0]+\
  219. @time_scale[1]*0xffffffff
  220. end

  221. #-=====================-#
  222. # 获取起始滴答数
  223. #-=====================-#
  224. def start()
  225. return @time_start.unpack('LL')[0]+\
  226. @time_start.unpack('LL')[1]*0xffffffff
  227. end

  228. #-=====================-#
  229. # 获取当前的嘀哒数
  230. #-=====================-#
  231. def timer()
  232. if @perf_flag
  233. @qpCounter.call(@time_now)
  234. else
  235. @time_now=[@tGetTime.call(),0].pack('LL')
  236. end
  237. return @time_now.unpack('LL')[0]+\
  238. @time_now.unpack('LL')[1]*0xffffffff
  239. end
  240. end
  241. #-------------------------------------#
  242. # 初始化自身成一个全局变量
  243. #-------------------------------------#
  244. $sys_timer=SystemTimer.new()
  245. #-------------------------------------#

  246. #==============================================================================
  247. # 仭 EasyConv module - Ver 0.90
  248. #------------------------------------------------------------------------------
  249. # Moonlight INN
  250. # http://cgi.members.interq.or.jp/aquarius/rasetsu/
  251. # RaTTiE
  252. # [email protected]
  253. #------------------------------------------------------------
  254. # EasyConv::s2u(text) : S-JIS -> UTF-8
  255. # EasyConv::u2s(text) : UTF-8 -> S-JIS
  256. #==============================================================================
  257. module EasyConv
  258. # API梡掕悢掕媊
  259. CP_ACP = 0
  260. CP_UTF8 = 65001

  261. #--------------------------------------------------------------------------
  262. # 仠 S-JIS -> UTF-8
  263. #--------------------------------------------------------------------------
  264. def s2u(text)
  265. # API掕媊
  266. m2w = Win32API.new('kernel32', 'MultiByteToWideChar', 'ilpipi', 'i')
  267. w2m = Win32API.new('kernel32', 'WideCharToMultiByte', 'ilpipipp', 'i')

  268. # S-JIS -> Unicode
  269. len = m2w.call(CP_ACP, 0, text, -1, nil, 0);
  270. buf = "\0" * (len*2)
  271. m2w.call(CP_ACP, 0, text, -1, buf, buf.size/2);

  272. # Unicode -> UTF-8
  273. len = w2m.call(CP_UTF8, 0, buf, -1, nil, 0, nil, nil);
  274. ret = "\0" * len
  275. w2m.call(CP_UTF8, 0, buf, -1, ret, ret.size, nil, nil);

  276. return ret
  277. end
  278. # module_function偲偟偰岞奐
  279. module_function :s2u
  280. #--------------------------------------------------------------------------
  281. # 仠 UTF-8 -> S-JIS
  282. #--------------------------------------------------------------------------
  283. def u2s(text)
  284. # API掕媊
  285. m2w = Win32API.new('kernel32', 'MultiByteToWideChar', 'ilpipi', 'i')
  286. w2m = Win32API.new('kernel32', 'WideCharToMultiByte', 'ilpipipp', 'i')

  287. # UTF-8 -> Unicode
  288. len = m2w.call(CP_UTF8, 0, text, -1, nil, 0);
  289. buf = "\0" * (len*2)
  290. m2w.call(CP_UTF8, 0, text, -1, buf, buf.size/2);

  291. # Unicode -> S-JIS
  292. len = w2m.call(CP_ACP, 0, buf, -1, nil, 0, nil, nil);
  293. ret = "\0" * len
  294. w2m.call(CP_ACP, 0, buf, -1, ret, ret.size, nil, nil);

  295. return ret
  296. end
  297. # module_function偲偟偰岞奐
  298. module_function :u2s
  299. end


  300. #==============================================================================
  301. # ■ Game_System
  302. #------------------------------------------------------------------------------
  303. #  处理系统附属数据的类。也可执行诸如 BGM 管理之类的功能。本类的实例请参考
  304. # $game_system 。
  305. #==============================================================================
  306. class Game_System
  307. #--------------------------------------------------------------------------
  308. # ● 定义实例变量
  309. #--------------------------------------------------------------------------
  310. attr_accessor :mtv_begin_time
  311. attr_accessor :mtv_now
  312. attr_accessor :mtv_length
  313. #--------------------------------------------------------------------------
  314. # ● 初始化对像
  315. #--------------------------------------------------------------------------
  316. alias mtv_gamesystem_initialize initialize
  317. def initialize
  318.   mtv_gamesystem_initialize
  319.   @mtv_begin_time = $sys_timer.now()
  320.   @mtv_now = false
  321.   @mtv_length = 0
  322. end
  323. end  

  324. #==============================================================================
  325. # ■ Scene_Map
  326. #------------------------------------------------------------------------------
  327. #  处理地图画面的类。
  328. #==============================================================================
  329. class Scene_Map
  330. #--------------------------------------------------------------------------
  331. # ● 刷新画面
  332. #--------------------------------------------------------------------------
  333. alias mtv_scenemap_update update
  334. def update
  335.   MTV.new_text
  336.   @mtv_window.refresh
  337.   mtv_scenemap_update
  338. end
  339. #--------------------------------------------------------------------------
  340. # ● 主处理
  341. #--------------------------------------------------------------------------
  342. alias mtv_scenemap_main main
  343. def main
  344.   @mtv_window = Window_MTV.new
  345.   mtv_scenemap_main
  346.   @mtv_window.dispose
  347. end
  348. #--------------------------------------------------------------------------
  349. # ● 调用战斗 (调整自动切换BGM)
  350. #--------------------------------------------------------------------------
  351. def call_battle
  352.   # 清除战斗调用标志
  353.   $game_temp.battle_calling = false
  354.   # 清除菜单调用标志
  355.   $game_temp.menu_calling = false
  356.   $game_temp.menu_beep = false
  357.   # 生成遇敌计数
  358.   $game_player.make_encounter_count
  359.   # 记忆地图 BGM 、停止 BGM
  360.   $game_temp.map_bgm = $game_system.playing_bgm
  361.   unless MTV.mtv?      
  362.     $game_system.bgm_play($game_system.battle_bgm)
  363.     # 演奏战斗开始 SE
  364.     $game_system.se_play($data_system.battle_start_se)
  365.   end
  366.   # 矫正主角姿势
  367.   $game_player.straighten
  368.   # 切换到战斗画面
  369.   $scene = Scene_Battle.new
  370. end
  371. end

  372. #==============================================================================
  373. # ■ Scene_Battle
  374. #------------------------------------------------------------------------------
  375. #  处理战斗的类。
  376. #==============================================================================
  377. class Scene_Battle
  378. #--------------------------------------------------------------------------
  379. # ● 刷新画面
  380. #--------------------------------------------------------------------------
  381. alias mtv_scenebattle_update update
  382. def update
  383.   @mtv_window.refresh
  384.   mtv_scenebattle_update
  385. end
  386. #--------------------------------------------------------------------------
  387. # ● 主处理
  388. #--------------------------------------------------------------------------
  389. alias mtv_scenebattle_main main
  390. def main
  391.   @mtv_window = Window_MTV.new
  392.   mtv_scenebattle_main
  393.   @mtv_window.dispose
  394. end
  395. end

  396. #==============================================================================
  397. # ■ Window_MTV
  398. #------------------------------------------------------------------------------
  399. #  显示MTV字幕的窗口。
  400. #==============================================================================

  401. class Window_MTV < Window_Base
  402. #--------------------------------------------------------------------------
  403. # ● 初始化窗口
  404. #--------------------------------------------------------------------------
  405.   def initialize
  406.     super(0, 416, 640, 64)
  407.     self.contents = Bitmap.new(width - 32, height - 32)
  408.     $lrc_text = ""
  409.     self.z = 9999
  410.     #===========================
  411.     # 时间有限
  412.     @temp_text = ""
  413.     $game_temp.old_text = ""
  414.     # 面粉无敌
  415.     #===========================
  416.     refresh
  417.    
  418.   end
  419. #--------------------------------------------------------------------------
  420. # ● 刷新
  421. #--------------------------------------------------------------------------
  422.   def refresh(text = "")
  423.     #=================================================
  424.     # 时间有限
  425.     if $game_temp.in_battle
  426.       self.opacity = 120
  427.     else
  428.       self.opacity = 0
  429.     end
  430.     if $game_system.mtv_now == false or $lrc_text == ""
  431.       self.contents.clear
  432.       else
  433.     if $game_temp.refresh_times != 1
  434.       if $game_temp.old_text != @temp_text
  435.         self.contents.clear
  436.         self.contents.font.color = FONT_COLOR
  437.         self.contents.font.size = FONT_SIZE
  438.         self.contents.font.name = FONT_NAME
  439.         self.contents.draw_text(0, 0, 608, 32, $lrc_text, 1)   
  440.         self.contents.font.color = Color.new(255,255,255,255)
  441.         self.contents.draw_text(1, 1, 608, 32, $lrc_text, 1)
  442.         @temp_text = $lrc_text
  443.       end
  444.     else
  445.       self.contents.clear
  446.       self.contents.font.color = FONT_COLOR
  447.       self.contents.font.size = FONT_SIZE
  448.       self.contents.font.name = FONT_NAME
  449.       self.contents.draw_text(0, 0, 608, 32, $lrc_text, 1)   
  450.       self.contents.font.color = Color.new(255,255,255,255)
  451.       self.contents.draw_text(1, 1, 608, 32, $lrc_text, 1)
  452.       @temp_text = $lrc_text
  453.       end
  454.     end
  455.     # 面粉无敌
  456.     #==================================================
  457.   end
  458. end
复制代码

点评

我能加你QQ吗?我的是704562646  发表于 2012-7-20 17:11
我看了你的作品,很精美、很感人。神作啊 我要的功能,你的作品都体现了 我现在学习你的脚本中....谢谢  发表于 2012-7-20 17:10
[url=http://weibo.com/2238291690?s=6uyXnP]
回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
5 小时
注册时间
2012-7-16
帖子
33
3
发表于 2012-7-20 14:30:12 | 只看该作者
6R不是有字幕滚动脚本吗?

点评

那个脚本不完全符合我的要求,尤其是最后一条  发表于 2012-7-20 14:31
回复

使用道具 举报

Lv2.观梦者

梦石
0
星屑
260
在线时间
1373 小时
注册时间
2005-10-16
帖子
5113

贵宾

4
发表于 2012-7-20 14:42:25 | 只看该作者
就是说文字在显示的时候,还要可以正常的可以进行游戏,这样?
我只个搬答案的
叔叔我已经当爹了~
婚后闪人了……
回复

使用道具 举报

Lv2.观梦者


  • 更新完成啦

梦石
0
星屑
769
在线时间
6267 小时
注册时间
2006-6-7
帖子
8462
5
发表于 2012-7-21 14:34:21 | 只看该作者
七夕小雨 发表于 2012-7-20 15:00
试试看很古老的MTV脚本呢?我把颜色、字体、字号都提取出来了,方便你使用

范例工程传送门:http://115.co ...

小甜甜。。http://www.66rpg.com/articles/4456

点评

= =不是要改变字号什么的嘛?所以我是从传送门脚本修改的  发表于 2012-7-21 15:38
回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
49
在线时间
71 小时
注册时间
2011-12-24
帖子
180
6
发表于 2012-7-28 09:46:53 | 只看该作者
哇塞,你们都是牛人啊!55555555~可惜我是个纯新手

点评

我看是水神……  发表于 2013-2-19 15:17

赏金猎人 -- Bounty Hunter 预告贴(点击图片或者这里进入
回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
49
在线时间
14 小时
注册时间
2013-2-17
帖子
41
7
发表于 2013-2-19 15:18:43 | 只看该作者
请问只能播放一首?
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-4-29 23:41

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表