查看: 2180|回复: 2

[推荐问答] 怎么样设置碰到不可通行块就发出音效

[复制链接]
梦石
0
星屑
47
在线时间
253 小时
注册时间
2012-8-2
回帖
190
发表于 2012-9-23 15:22:49 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
本帖最后由 hys111111 于 2012-9-24 17:50 编辑

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

点评

3帧?3帧一丢丢就过去了 = =  发表于 2012-10-7 12:07

评分

参与人数 1星屑 +100 收起 理由
hys111111 + 100 技术问题

查看全部评分

梦石
0
星屑
672
在线时间
2184 小时
注册时间
2009-12-6
回帖
571

开拓者

发表于 2012-9-23 20:00:30 | 显示全部楼层
本帖最后由 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]

点评

在问一下。。 怎么设置撞到后等待3帧  发表于 2012-9-23 21:58

评分

参与人数 1星屑 +200 梦石 +2 收起 理由
hys111111 + 200 + 2 认可答案

查看全部评分

往事简直不堪回首,稍微做点想做的事吧
回复

使用道具 举报

梦石
0
星屑
47
在线时间
253 小时
注册时间
2012-8-2
回帖
190
 楼主| 发表于 2012-9-23 20:53:54 | 显示全部楼层
ML4455739 发表于 2012-9-23 20:00
# 关闭判定的开关ID,默认5号开关为ON时关闭判定
  JUDGE_SWITCHES = 5

真感谢。。   
回复

使用道具 举报

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

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部