本帖最后由 精灵使者 于 2014-11-24 18:37 编辑
精灵使者 发表于 2014-11-21 23:36
那个,不需要获取MP3的ID3标签啦。
只需要获取正在播放的文件名就可以了的说。
补充:
写了一个循环显示BGM的脚本,没有做ME的,可以试试效果。
class BGM_Display def initialize @bgm = nil @me = nil @waiting = 0 @sprite1 = Sprite.new @sprite2 = Sprite.new @sprite1.bitmap = Bitmap.new(160, 32) @sprite2.bitmap = Bitmap.new(160, 224) @sprite2.src_rect = Rect.new(0, 0, 160, 32) self.x = 480 self.y = 416 self.z = 999 refresh end def refresh if @me == nil || @me.name =="" if @bgm == nil || @bgm.name == "" @sprite2.bitmap.clear return end @sprite1.bitmap.clear @sprite1.bitmap.draw_text(0, 0, 160, 32, "BGM:") @texts = @bgm.name.split(/-/) else @sprite1.bitmap.clear @sprite1.bitmap.draw_text(0, 0, 160, 32, "ME:") @texts = @me.name.split(/-/) end ([email]0...@texts.size[/email]).each do |i| draw_item(i) end end def draw_item(i) x = 4 y = 32 * (2 * i + 1) @sprite2.bitmap.fill_rect(x, y, 160, 32, Color.new(0,0,0,0)) @sprite2.bitmap.draw_text(x, y ,160, 32, @texts[i]) end def x=(x) @sprite1.x = x @sprite2.x = x end def y=(y) @sprite1.y = y @sprite2.y = y + 32 end def z=(z) @sprite1.z = z @sprite2.z = z end def update if $game_temp.playing_me != nil @me = $game_temp.playing_me $game_temp.playing_me = nil refresh @sprite2.src_rect.y = 0 return end if $game_system.playing_bgm != @bgm @bgm = $game_system.playing_bgm refresh @sprite2.src_rect.y = 0 return end if @waiting > 0 @waiting -= 1 return end @sprite2.src_rect.y += 1 if @sprite2.src_rect.y >= 192 @sprite2.src_rect.y -= 192 if @me != nil @me = nil refresh end end if @sprite2.src_rect.y % 64 == 32 @waiting = 40 end end def dispose @sprite1.bitmap.dispose @sprite2.bitmap.dispose @sprite1.dispose @sprite2.dispose end end class Game_Temp attr_accessor :playing_me end class Game_System alias rb_me_play_20141124 me_play def me_play(me) $game_temp.playing_me = me rb_me_play_20141124(me) end end class Scene_Map alias rb_main_20141122 main def main @bgm_display = BGM_Display.new rb_main_20141122 @bgm_display.dispose end alias rb_update_20141122 update def update @bgm_display.update rb_update_20141122 end end
class BGM_Display
def initialize
@bgm = nil
@me = nil
@waiting = 0
@sprite1 = Sprite.new
@sprite2 = Sprite.new
@sprite1.bitmap = Bitmap.new(160, 32)
@sprite2.bitmap = Bitmap.new(160, 224)
@sprite2.src_rect = Rect.new(0, 0, 160, 32)
self.x = 480
self.y = 416
self.z = 999
refresh
end
def refresh
if @me == nil || @me.name ==""
if @bgm == nil || @bgm.name == ""
@sprite2.bitmap.clear
return
end
@sprite1.bitmap.clear
@sprite1.bitmap.draw_text(0, 0, 160, 32, "BGM:")
@texts = @bgm.name.split(/-/)
else
@sprite1.bitmap.clear
@sprite1.bitmap.draw_text(0, 0, 160, 32, "ME:")
@texts = @me.name.split(/-/)
end
([email]0...@texts.size[/email]).each do |i|
draw_item(i)
end
end
def draw_item(i)
x = 4
y = 32 * (2 * i + 1)
@sprite2.bitmap.fill_rect(x, y, 160, 32, Color.new(0,0,0,0))
@sprite2.bitmap.draw_text(x, y ,160, 32, @texts[i])
end
def x=(x)
@sprite1.x = x
@sprite2.x = x
end
def y=(y)
@sprite1.y = y
@sprite2.y = y + 32
end
def z=(z)
@sprite1.z = z
@sprite2.z = z
end
def update
if $game_temp.playing_me != nil
@me = $game_temp.playing_me
$game_temp.playing_me = nil
refresh
@sprite2.src_rect.y = 0
return
end
if $game_system.playing_bgm != @bgm
@bgm = $game_system.playing_bgm
refresh
@sprite2.src_rect.y = 0
return
end
if @waiting > 0
@waiting -= 1
return
end
@sprite2.src_rect.y += 1
if @sprite2.src_rect.y >= 192
@sprite2.src_rect.y -= 192
if @me != nil
@me = nil
refresh
end
end
if @sprite2.src_rect.y % 64 == 32
@waiting = 40
end
end
def dispose
@sprite1.bitmap.dispose
@sprite2.bitmap.dispose
@sprite1.dispose
@sprite2.dispose
end
end
class Game_Temp
attr_accessor :playing_me
end
class Game_System
alias rb_me_play_20141124 me_play
def me_play(me)
$game_temp.playing_me = me
rb_me_play_20141124(me)
end
end
class Scene_Map
alias rb_main_20141122 main
def main
@bgm_display = BGM_Display.new
rb_main_20141122
@bgm_display.dispose
end
alias rb_update_20141122 update
def update
@bgm_display.update
rb_update_20141122
end
end
|