找回密码
 点一下
查看: 2766|回复: 3

播放可重复3d音效的完美实现

[复制链接]
发表于 2011-7-14 16:17:18 | 显示全部楼层 |阅读模式
        3d音效是会有循序渐弱效果的。需要在声音编辑器里 把它用作音效 然后双击3d音效挑勾,但也只能在声音播放完毕后才能再次播放。
那么怎么重复播放,用路径的方法。以前有帖子曾提到过非3D。而3D的需要事先设置一下,也就是这样:

[jass]
function dsound takes string s, unit u returns nothing
    set bj_lastPlayedSound =CreateSound( "war3mapImported\\"+s, false, true, false, 10, 10, "DefaultEAXON" )
    call SetSoundDistances( bj_lastPlayedSound, 1000.0, 4000.0 )
    call SetSoundDistanceCutoff( bj_lastPlayedSound, 4000.0 )
    call SetSoundPosition(bj_lastPlayedSound, GetUnitX(u), GetUnitY(u), 0)
    call StartSound(bj_lastPlayedSound)
    call KillSoundWhenDone(bj_lastPlayedSound)
endfunction
function usound takes string s, unit u returns nothing
    set bj_lastPlayedSound =CreateSound( "war3mapImported\\"+s, false, true, false, 10, 10, "DefaultEAXON" )
    call SetSoundDistances( bj_lastPlayedSound, 1000.0, 8000.0 )
    call SetSoundDistanceCutoff( bj_lastPlayedSound, 8000.0 )
    call AttachSoundToUnit( bj_lastPlayedSound, u)
    call StartSound(bj_lastPlayedSound)
    call KillSoundWhenDone(bj_lastPlayedSound)
endfunction
function CInitSound takes string s, unit u returns nothing
    set bj_lastPlayedSound =CreateSound( "war3mapImported\\"+s, false, true, false, 10, 10, "DefaultEAXON" )
    call SetSoundDistanceCutoff( bj_lastPlayedSound, 4000.0 )
    call SetSoundPosition(bj_lastPlayedSound, GetUnitX(u), GetUnitY(u), 0)
    call StartSound(bj_lastPlayedSound)
    call StopSound( bj_lastPlayedSound,false,false)
    call KillSoundWhenDone(bj_lastPlayedSound)
endfunction
[/jass]

        以后当需要在点播放音效的时候就可以直接调用了比如播放在单位位置 dsound("s",u),当然路径后的.文件后缀不要忘了写。参数自己定义,这样声音编辑器里的用作音效都省去了
        不过还有几个问题需要注意:


*不能播放MP3立体声的声音 也就是说只能用MP3单声道和wav。
单声道MP3在声音编辑器是不能用于3d音效的。而双声道3d播放也不出。

*第一次播放声音不会出来,需要预播放一次 简称初始化吧,而初始化时也要注意
声音编辑器里用作音效是没有意思的,少了播放所以白搭  因此要在触发内执行,而地图初始化时是不能播放声音的,所以注册游戏开始0秒事件后播放
关于玩家开始点 必须在3d音效声音截断范围之内,否则没有波及到还是相当于没有初始化。

*如果播放跟初始化用的是同一个函数比如dsound(,)那么声音播放正常,但在F10-E-R重新开始单人游戏后 由于地图有些内存未被释放,所以0秒后所有声音齐鸣
避免这样,还要在用一个专门初始化函数,CInitSound()只少了设置衰减范围的动作,多了停止。缺少stactic用法只好多写一个函数


这样就可以实现同时播放多次的3D音效。
可重复3d音效.w3x (126 KB, 下载次数: 279)

评分

参与人数 1威望 +32 收起 理由
希瓦 + 32 不错的演示

查看全部评分

 楼主| 发表于 2011-7-14 23:23:39 | 显示全部楼层
个人感觉相当给力,尤其是需要用到大量音效的人
当然有更好的方法也欢迎指出
回复

使用道具 举报

发表于 2011-7-22 17:07:19 | 显示全部楼层
好东西,谢谢LZ。这个终于解决了
回复

使用道具 举报

发表于 2011-7-14 20:28:01 | 显示全部楼层
很不错!!顶一个!!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 点一下

本版积分规则

Archiver|移动端|小黑屋|地精研究院

GMT+8, 2024-4-25 02:15 , Processed in 0.632684 second(s), 22 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表