Project1

标题: 问下动画播放的问题 [打印本页]

作者: Wind2010    时间: 2011-2-14 12:06
标题: 问下动画播放的问题
  1. class Game_System
  2.   attr_accessor :music_num
  3.   attr_accessor :sound_num
  4.   attr_accessor :auto_save
  5.   alias shizi_initialize initialize
  6.   def initialize
  7.     shizi_initialize
  8.     @music_num = 100
  9.     @sound_num = 100
  10.     @auto_save = false
  11.   end
  12.   def bgm_play(bgm)
  13.     @playing_bgm = bgm
  14.     if bgm != nil and bgm.name != ""
  15.       Audio.bgm_play("Audio/BGM/" + bgm.name, bgm.volume * @music_num / 100, bgm.pitch)
  16.     else
  17.       Audio.bgm_stop
  18.     end
  19.     Graphics.frame_reset
  20.   end
  21.   def bgs_play(bgs)
  22.     @playing_bgs = bgs
  23.     if bgs != nil and bgs.name != ""
  24.       Audio.bgs_play("Audio/BGS/" + bgs.name, bgs.volume * @music_num / 100, bgs.pitch)
  25.     else
  26.       Audio.bgs_stop
  27.     end
  28.     Graphics.frame_reset
  29.   end
  30.   def me_play(me)
  31.     if me != nil and me.name != ""
  32.       Audio.me_play("Audio/ME/" + me.name, me.volume * @sound_num / 100, me.pitch)
  33.     else
  34.       Audio.me_stop
  35.     end
  36.     Graphics.frame_reset
  37.   end
  38.   def se_play(se)
  39.     if se != nil and se.name != ""
  40.       Audio.se_play("Audio/SE/" + se.name, se.volume * @sound_num / 100, se.pitch)
  41.     end
  42.   end
  43. end
  44. class Scene_Select
  45.   def main
  46.     @screen = Spriteset_Map.new
  47.     s1 = " 音乐 "
  48.     s2 = " 音效 "
  49.     s3 = "自动存档"
  50.     @wd1 = Window_Command.new(128,[s1,s2,s3])
  51.     @wd1.x = 158
  52.     @wd1.y = 176
  53.     @wd2 = Window_Base.new(0,0,324,128)
  54.     @wd2.contents = Bitmap.new(292,96)
  55.     @wd2.x = 158
  56.     @wd2.y = 176
  57.     @wd2.active = false
  58.     wd2_refresh
  59.     @wd3 = Window_Base.new(0,0,324,128)
  60.     @wd3.contents = Bitmap.new(292,96)
  61.     @wd3.x = 158
  62.     @wd3.y = 176
  63.     wd3_refresh
  64.     @wd4 = Window_Base.new(0,0,324,128)
  65.     @wd4.contents = Bitmap.new(292,96)
  66.     @wd4.x = 158
  67.     @wd4.y = 176
  68.     @wd4.active = false
  69.     wd4_refresh
  70.     Graphics.transition
  71.     loop do
  72.       Graphics.update
  73.       Input.update
  74.       update
  75.       if $scene != self
  76.         break
  77.       end
  78.     end
  79.     Graphics.freeze
  80.     @screen.dispose
  81.     @wd1.dispose
  82.     @wd2.dispose
  83.     @wd3.dispose
  84.     @wd4.dispose
  85.   end
  86.   def update
  87.     $windspeed.update
  88.     if @wd2.active
  89.       return music_update
  90.     end
  91.     if @wd4.active
  92.       return sound_update
  93.     end
  94.     @wd1.update
  95.     if Input.trigger?(Input::B)
  96.       $game_system.se_play($data_system.cancel_se)
  97.       $scene = Scene_Map.new
  98.       return
  99.     end
  100.     if Input.trigger?(Input::C)
  101.       $game_system.se_play($data_system.decision_se)
  102.       case @wd1.index
  103.       when 0
  104.         @wd2.active = true
  105.         @wd1.active = false
  106.       when 1
  107.         @wd4.active = true
  108.         @wd1.active = false
  109.       when 2
  110.         $game_system.auto_save ? $game_system.auto_save = false : $game_system.auto_save = true
  111.         wd3_refresh
  112.       end
  113.     end
  114.   end
  115.   def wd2_refresh
  116.     @wd2.contents.clear
  117.     @wd2.contents.fill_rect(128,14,102,4,Color.new(255,255,255,255))
  118.     @wd2.contents.fill_rect(129,15,100,2,Color.new(25,25,255,255))
  119.     @wd2.contents.fill_rect(126+$game_system.music_num,11,4,10,Color.new(255,255,255,255))
  120.     @wd2.contents.draw_text(235,0,100,32,$game_system.music_num.to_s)
  121.   end
  122.   def wd4_refresh
  123.     @wd4.contents.clear
  124.     @wd4.contents.fill_rect(128,46,102,4,Color.new(255,255,255,255))
  125.     @wd4.contents.fill_rect(129,47,100,2,Color.new(25,25,255,255))
  126.     @wd4.contents.fill_rect(126+$game_system.sound_num,43,4,10,Color.new(255,255,255,255))
  127.     @wd4.contents.draw_text(235,32,100,32,$game_system.sound_num.to_s)
  128.   end
  129.   def wd3_refresh
  130.     @wd3.contents.clear
  131.     $game_system.auto_save ? @wd3.contents.draw_text(128,64,164,32,"开",1) : @wd3.contents.draw_text(128,64,164,32,"关",1)
  132.   end
  133.   def music_update
  134.     if Input.trigger?(Input::B)
  135.       $game_system.se_play($data_system.cancel_se)
  136.       @wd2.active = false
  137.       @wd1.active = true
  138.     end
  139.     if Mouse.press?(Mouse::LEFT)
  140.       mouse_x, mouse_y = Mouse.get_mouse_pos
  141.       if mouse_x >= 302 and mouse_x <= 402 and mouse_y >= 203 and mouse_y <= 213
  142.         @music = mouse_x - 302
  143.         if @music != $game_system.music_num
  144.           $game_system.music_num = @music
  145.           $game_system.bgm_play($game_system.playing_bgm)
  146.           $game_system.bgs_play($game_system.playing_bgs)
  147.           Audio.se_play("Audio/SE/032-Switch01",100 * $game_system.sound_num / 100)
  148.           wd2_refresh
  149.         end
  150.       end
  151.     end
  152.     if Input.repeat?(Input::LEFT) and $game_system.music_num > 0
  153.       Audio.se_play("Audio/SE/032-Switch01",100 * $game_system.sound_num / 100)
  154.       $game_system.music_num -= 1
  155.       $game_system.bgm_play($game_system.playing_bgm)
  156.       $game_system.bgs_play($game_system.playing_bgs)
  157.       wd2_refresh
  158.     end
  159.     if Input.repeat?(Input::RIGHT) and $game_system.music_num < 100
  160.       Audio.se_play("Audio/SE/032-Switch01",100 * $game_system.sound_num / 100)
  161.       $game_system.music_num += 1
  162.       $game_system.bgm_play($game_system.playing_bgm)
  163.       $game_system.bgs_play($game_system.playing_bgs)
  164.       wd2_refresh
  165.     end
  166.   end
  167.   def sound_update
  168.     if Input.trigger?(Input::B)
  169.       $game_system.se_play($data_system.cancel_se)
  170.       @wd4.active = false
  171.       @wd1.active = true
  172.     end
  173.     if Mouse.press?(Mouse::LEFT)
  174.       mouse_x, mouse_y = Mouse.get_mouse_pos
  175.       if mouse_x >= 302 and mouse_x <= 402 and mouse_y >= 235 and mouse_y <= 245
  176.         @sound = mouse_x - 302
  177.         if @sound != $game_system.sound_num
  178.           Audio.se_play("Audio/SE/032-Switch01",100 * $game_system.sound_num / 100)
  179.           $game_system.sound_num = @sound
  180.           wd4_refresh
  181.         end
  182.       end
  183.     end
  184.     if Input.repeat?(Input::LEFT) and $game_system.sound_num > 0
  185.       Audio.se_play("Audio/SE/032-Switch01",100 * $game_system.sound_num / 100)
  186.       $game_system.sound_num -= 1
  187.       wd4_refresh
  188.     end
  189.     if Input.repeat?(Input::RIGHT) and $game_system.sound_num < 100
  190.       Audio.se_play("Audio/SE/032-Switch01",100 * $game_system.sound_num / 100)
  191.       $game_system.sound_num += 1
  192.       wd4_refresh
  193.     end
  194.   end
  195. end
  196. class Scene_Map
  197.   alias shizixd update
  198.   def update
  199.     auto_save if $game_system.auto_save
  200.     shizixd
  201.   end
  202. def auto_save
  203.   cundang if $game_variables[1] == 0
  204.     if $game_variables[1] != 0
  205.       filename = "Save#{$game_variables[1]}.rxdata"
  206.       file = File.open(filename, "wb")
  207.       characters = []
  208.       for i in 0...$game_party.actors.size
  209.         actor = $game_party.actors[i]
  210.         characters.push([actor.character_name, actor.character_hue])
  211.       end
  212.       Marshal.dump(characters, file)
  213.       $game_system.magic_number = $data_system.magic_number
  214.       Marshal.dump(Graphics.frame_count, file)
  215.       Marshal.dump($game_system, file)
  216.       Marshal.dump($game_switches, file)
  217.       Marshal.dump($game_variables, file)
  218.       Marshal.dump($game_self_switches, file)
  219.       Marshal.dump($game_screen, file)
  220.       Marshal.dump($game_actors, file)
  221.       Marshal.dump($game_party, file)
  222.       Marshal.dump($game_troop, file)
  223.       Marshal.dump($game_map, file)
  224.       Marshal.dump($game_player, file)
  225.       file.close
  226.     end
  227.   end
  228. end
复制代码
自己写了一个改变音量的脚本,一般的声音都可以改变音量,但是在播放动画时,动画的SE音量大小不能控制。怎样才可以把动画的SE音量也改变?dsu_plus_rewardpost_czw
作者: Wind2010    时间: 2011-2-15 12:14
本帖最后由 Wind2010 于 2011-2-15 12:14 编辑

1天自顶...
作者: tamashii    时间: 2011-2-15 13:12
动画中的se是在数据库中存储的吧
不行的话重写Audio模型
  1. module Audio
  2.   alias bgm_play old_bgm
  3.   def self.bgm_play(filename, volume = 100, pitch = 100)
  4.     old_bgm(filename, 音量, pitch)
  5.   end
  6. end
复制代码

作者: Wind2010    时间: 2011-2-15 13:15
回复 tamashii 的帖子

BGS、ME、SE都可以这样子吗?
作者: tamashii    时间: 2011-2-15 13:23
本帖最后由 tamashii 于 2011-2-15 13:33 编辑

那看来是我的代码错了

  1. module Audio
  2.   alias old_bgm bgm_play
  3.   def self.bgm_play(filename, volume=100, pitch=100)
  4.     old_bgm(filename, 100, pitch)
  5.   end
  6. end
复制代码
这回再试试
作者: Wind2010    时间: 2011-2-16 20:58
自顶....




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1