cocos2d-x背景音乐和音效

前端之家收集整理的这篇文章主要介绍了cocos2d-x背景音乐和音效前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

1.文件包含:

#include "cocos2d.h"
#include "SimpleAudioEngine.h"
using namespace CocosDenshion;

2.直接使用即可:

//一:播放背景音乐
    ////1.预加载背景音乐
    //SimpleAudioEngine::getInstance()->preloadBackgroundMusic("Sound/background.mp3");
    ////2.声音大小(0.0-1.0)手机上可用,Pc机不可用。
    //SimpleAudioEngine::getInstance()->setBackgroundMusicVolume(0.5);
    ////3.设置循环播放
    //SimpleAudioEngine::getInstance()->playBackgroundMusic("Sound/background.mp3",true);
    ////暂停
    //SimpleAudioEngine::getInstance()->pauseBackgroundMusic();
    ////继续
    //SimpleAudioEngine::getInstance()->resumeBackgroundMusic();
    ////停止
    //SimpleAudioEngine::getInstance()->stopBackgroundMusic();

    ////二:播放音效
    ////1.预加载音效
    //SimpleAudioEngine::getInstance()->preloadEffect("Sound/effect1.wav");
    ////2.播发音效
    //SimpleAudioEngine::getInstance()->playEffect("Sound/effect1.wav");
原文链接:https://www.f2er.com/cocos2dx/340510.html

猜你在找的Cocos2d-x相关文章