cocos2d-x 同時播放多個音效的時候,會發現有的音效放不出,有的循環音效放着放着就沒了
後來發現貓膩在Cocos2dxSound.java裏:
private static final int MAX_SIMULTANEOUS_STREAMS_DEFAULT = 5;
SoundPool構造的時候要指定併發音頻流的數量
public SoundPool (int maxStreams, int streamType, int srcQuality)
Added in API level 1
This constructor was deprecated in API level 21.
use SoundPool.Builder
instead to create and configure a SoundPool instance
Constructor. Constructs a SoundPool object with the following characteristics:
Parameters
maxStreams | 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 use STREAM_MUSIC . |
srcQuality | the sample-rate converter quality. Currently has no effect. Use 0 for the default. |
Returns
a SoundPool object, or null if creation failed
這裏cocos2d-x設置成5了(I9100設成3),可以手動改大一點,來解決問題
版本:cocos2d-x 3.0