secondsen 发表于 2009-12-8 20:38:33

VX 调节音量

完全的入门级。。。没有比这个简单的了。。。

在游戏中用脚本调下面的4个全局变量即可。。。。0~100.。。也可以试试大于100会怎么样。。。。

没有写存档部分。。。有人要用的话可别忘记把这个四个全局存读档啊。。。。
$bgm = 100
$bgs = 100
$se = 100
$me = 100
module RPG
class BGM < AudioFile
    def play
      if @name.empty?
      Audio.bgm_stop
      @@last = BGM.new
      else
      volume = @volume * $bgm / 100.0
      Audio.bgm_play("Audio/BGM/" + @name, volume, @pitch)
      @@last = self
      end
    end
end
class BGS < AudioFile
    def play
      if @name.empty?
      Audio.bgs_stop
      @@last = BGS.new
      else
      volume = @volume * $bgs / 100.0
      Audio.bgs_play("Audio/BGS/" + @name, volume, @pitch)
      @@last = self
      end
    end
end
class ME < AudioFile
    def play
      if @name.empty?
      Audio.me_stop
      else
      volume = @volume * $me / 100.0
      Audio.me_play("Audio/ME/" + @name, volume, @pitch)
      end
    end
end
class SE < AudioFile
    def play
      unless @name.empty?
      volume = @volume * $se / 100.0
      Audio.se_play("Audio/SE/" + @name, volume, @pitch)
      end
    end
end
end

神思 发表于 2009-12-9 01:17:02

= =代码有些累赘,其实可以缩减很多...

secondsen 发表于 2009-12-9 10:15:25

how

secondsen 发表于 2009-12-9 16:34:53

怎么说了半截话就没影了。。。怎么改得不累赘啊

神思 发表于 2009-12-10 00:24:06

你何不直接重定义
Audio.se_play
Audio.me_play
Audio.bgm_play
这三个方法?

secondsen 发表于 2009-12-10 20:48:44

那用alias 怎么作用在 def Audio.bgm_play(f,v,p) 啊?
def a
end
alias b a
def a
b
end

这样行

但是加了Audio.那就不一样了。。总是不行,alias是咋回事啊?

神思 发表于 2009-12-10 23:50:21

因为Audio是一个模块...


无法alias 是因为类空间不同

module Audio
class << self
    def bgm_play(*avgc)
      p 1
    end
end
end

secondsen 发表于 2009-12-11 15:09:43

这种东西没有学过。。。我学习学习去。。。

secondsen 发表于 2009-12-11 16:21:28

module Audio
class << self
    alias old_bgm_play bgm_play
    def bgm_play(filename, volume = 100, pitch = 100)
      old_bgm_play(filename, volume * bgm/ 100.0, pitch)
    end
    alias old_bgs_play bgs_play
    def bgs_play(filename, volume = 100, pitch = 100)
      old_bgs_play(filename, volume * $bgs / 100.0, pitch)
    end
    alias old_se_play se_play
    def se_play(filename, volume = 100, pitch = 100)
      old_se_play(filename, volume * $se / 100.0, pitch)
    end
    alias old_me_play me_play
    def me_play(filename, volume = 100, pitch = 100)
      old_me_play(filename, volume * $me/ 100.0, pitch)
    end
end
end

This One

secondsen 发表于 2009-12-30 20:09:19

老早想编辑,结果总忘记。。。

这段脚本要加个开关
unless $secondsen
$secondsen = true
XXXX上面的脚本
end
页: [1]
查看完整版本: VX 调节音量