Cocoa2d-x 音乐与音效

本文详细介绍了CocosDenshion::SimpleAudioEngine库的使用方法,包括如何预加载音效和背景音乐,如何播放、停止和控制音乐效果。涵盖了从初始化到具体操作的全过程。
//---头文件---//
#include "SimpleAudioEngine.h"

//---单例指针---//

//---CocosDenshion::SimpleAudioEngine::sharedEngine()

//---预加载---//

void preloadEffect(const char* pszFilePath);  //音效

void preloadBackgroundMusic(const char* pszFilePath);  //背景音乐

//---播放---//

//音效  返回值为播放的id  第二参数是否循环
unsigned int playEffect(const char* pszFilePath, bool bLoop = false); 

//背景音乐  第二参数是否循环
void playBackgroundMusic(const char* pszFilePath, bool bLoop = false);

//---停止---//

void stopEffect(unsigned int nSoundId); //停止指定音效 参数为上面的id

void stopAllEffects();  //停止播放所有音效

void stopBackgroundMusic(); //停止播放背景音乐


//------------------------------//

CocosDenshion::SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic(); //重新开启音乐

CocosDenshion::SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic(); //暂停音乐

//--------------调用方式----------------//

CocosDenshion::SimpleAudioEngine::sharedEngine()->functions

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值