cocos2d-x 同时播放多个音效的时候,会发现有的音效放不出,有的循环音效放着放着就没了
后来发现猫腻在Cocos2dxSound.java里:
privatestaticfinalintMAX_SIMulTANEOUS_STREAMS_DEFAulT=5;
SoundPool构造的时候要指定并发音频流的数量
Added inAPI level 1
This constructor was deprecated in API level 21.
useSoundPool.Builder
instead to create and configure a SoundPool instance
Constructor. Constructs a SoundPool object with the following characteristics:
ParametersmaxStreams | the maximum number of simultaneous streams for this SoundPool object |
---|---|
streamType | the audio stream type as described in AudioManager For example,game applications will normally useSTREAM_MUSIC . |
srcQuality | the sample-rate converter quality. Currently has no effect. Use 0 for the default. |
a SoundPool object,or null if creation Failed
这里cocos2d-x设置成5了(I9100设成3),可以手动改大一点,来解决问题
版本:cocos2d-x 3.0
总结以上是内存溢出为你收集整理的cocos2d-x 同时播放多个音效的问题全部内容,希望文章能够帮你解决cocos2d-x 同时播放多个音效的问题所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)