Project1

标题: 怎么样设置碰到不可通行块就发出音效 [打印本页]

作者: tallboy8    时间: 2012-9-23 15:22
标题: 怎么样设置碰到不可通行块就发出音效
本帖最后由 hys111111 于 2012-9-24 17:50 编辑

怎样用脚本实现它?
因为是推荐问答,为了营造好的问答环境,不要纯表情,我已帮忙修改。看到问题的技术含量就不扣分了。
                                                                                             ——hys111111

作者: ML4455739    时间: 2012-9-23 20:00
本帖最后由 ML4455739 于 2012-9-23 20:03 编辑

[pre lang="ruby"]  # 关闭判定的开关ID,默认5号开关为ON时关闭判定
  JUDGE_SWITCHES = 5

  # 按键判定类型 true为press,false为trigger,可以尝试一下
  INPUT_TYPE = true # false
  
  # 音效文件名,无需路径,无需后缀名
  SE_NAME = "041-knock02"
  
  # 音效音量,最大100
  SE_VOLUME = 80
  
  # 音效延迟时间(默认40帧 = 1秒)
  SE_DELAY = 12
  
class Scene_Map
  
  def rwa_extra_voice_run_in
   
    td = $game_player
    return true if td.moving? or $game_switches[JUDGE_SWITCHES]
      
    case td.direction
    when 8
     if $game_map.check_event(td.x, td.y - 1).class != Fixnum
      if INPUT_TYPE
        return td.passable?(td.x, td.y - 1, td.direction) if Input.press?(Input::UP)
      else
        return td.passable?(td.x, td.y - 1, td.direction) if Input.trigger?(Input::UP)
      end
     end
    when 6
     if $game_map.check_event(td.x + 1, td.y).class != Fixnum
      if INPUT_TYPE
        return td.passable?(td.x + 1, td.y, td.direction) if Input.press?(Input::RIGHT)
      else
        return td.passable?(td.x + 1, td.y, td.direction) if Input.trigger?(Input::RIGHT)
      end
     end
    when 4
     if $game_map.check_event(td.x - 1, td.y).class != Fixnum
      if INPUT_TYPE
        return td.passable?(td.x - 1, td.y, td.direction) if Input.press?(Input::LEFT)
      else
        return td.passable?(td.x - 1, td.y, td.direction) if Input.trigger?(Input::LEFT)
      end
     end
    when 2
     if $game_map.check_event(td.x, td.y + 1).class != Fixnum
      if INPUT_TYPE
        return td.passable?(td.x, td.y + 1, td.direction) if Input.press?(Input::DOWN)
      else
        return td.passable?(td.x, td.y + 1, td.direction) if Input.trigger?(Input::DOWN)
      end # if INPUT_TYPE
     end # if $game_map.check_event
    end # case
      return true
  end # def
      
  alias rwa_extra_voice_run_in_update update
  def update
    rwa_extra_voice_run_in_update
    return if $game_switches[JUDGE_SWITCHES]
    if !$game_player.moving?
      @@tdtime    ||= []
      @@tdtime[0] ||= 0
      @@tdtime[1] ||= false
      @@tdtime[0] >= SE_DELAY ? @@tdtime[1] = true : @@tdtime[0] += 1
      @@tdtime[0] = 0 if @@tdtime[1]
    end

    if rwa_extra_voice_run_in == false and @@tdtime[1]
      Audio.se_play("Audio/SE/#{SE_NAME}", SE_VOLUME, 100)
      @@tdtime[1] = nil
    end # if
  end # def
  
end # class[/pre]
作者: tallboy8    时间: 2012-9-23 20:53
ML4455739 发表于 2012-9-23 20:00
# 关闭判定的开关ID,默认5号开关为ON时关闭判定
  JUDGE_SWITCHES = 5

真感谢。。   




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