本文整理汇总了C++中cocosdenshion::SimpleAudioEngine::stopBackgroundMusic方法的典型用法代码示例。如果您正苦于以下问题:C++ SimpleAudioEngine::stopBackgroundMusic方法的具体用法?C++ SimpleAudioEngine::stopBackgroundMusic怎么用?C++ SimpleAudioEngine::stopBackgroundMusic使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cocosdenshion::SimpleAudioEngine
的用法示例。
在下文中一共展示了SimpleAudioEngine::stopBackgroundMusic方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: lua_cocos2dx_cocosdenshion_SimpleAudioEngine_stopBackgroundMusic
int lua_cocos2dx_cocosdenshion_SimpleAudioEngine_stopBackgroundMusic(lua_State* tolua_S)
{
int argc = 0;
CocosDenshion::SimpleAudioEngine* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"cc.SimpleAudioEngine",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (CocosDenshion::SimpleAudioEngine*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_cocosdenshion_SimpleAudioEngine_stopBackgroundMusic'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_cocosdenshion_SimpleAudioEngine_stopBackgroundMusic'", nullptr);
return 0;
}
cobj->stopBackgroundMusic();
return 0;
}
if (argc == 1)
{
bool arg0;
ok &= luaval_to_boolean(tolua_S, 2,&arg0, "cc.SimpleAudioEngine:stopBackgroundMusic");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_cocosdenshion_SimpleAudioEngine_stopBackgroundMusic'", nullptr);
return 0;
}
cobj->stopBackgroundMusic(arg0);
return 0;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.SimpleAudioEngine:stopBackgroundMusic",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_cocosdenshion_SimpleAudioEngine_stopBackgroundMusic'.",&tolua_err);
#endif
return 0;
}
示例2: ccTouchBegan
bool GameScene::ccTouchBegan(cocos2d::CCTouch *pTouch, cocos2d::CCEvent *pEvent)
{
if(GameData::gameState == GameData::STATE_PAUSE)
{
return false;
}
else if(GameData::gameState == GameData::STATE_GAMEOVER)
{
CocosDenshion::SimpleAudioEngine* instance = CocosDenshion::SimpleAudioEngine::sharedEngine();
instance->stopBackgroundMusic();
CCScene* scene = CCTransitionFade::create(0.3f, MainScene::scene());
CCDirector::sharedDirector()->replaceScene(scene);
GameData::gameState = GameData::STATE_PLAYING;
return false;
}
int x = (CCDirector::sharedDirector()->convertToGL(pTouch->getLocationInView())).x;
if(x>450)
{
this->changeCharLine(true);
}
else
{
this->changeCharLine(false);
}
return false;
}
示例3: clickBtnExit
void GameScene::clickBtnExit(CCObject* pObject)
{
CocosDenshion::SimpleAudioEngine* instance = CocosDenshion::SimpleAudioEngine::sharedEngine();
instance->stopBackgroundMusic();
CCScene* scene = CCTransitionFade::create(0.3f, MainScene::scene());
CCDirector::sharedDirector()->replaceScene(scene);
// GameData::gameState = GameData::STATE_PLAYING;
}
示例4: startBackgroundMusic
void GameScene::startBackgroundMusic()
{
CocosDenshion::SimpleAudioEngine* instance = CocosDenshion::SimpleAudioEngine::sharedEngine();
instance->stopBackgroundMusic();
if(GameData::isMusicSound)
{
instance->playBackgroundMusic("game.wav", true);
}
}
示例5: menuMusicCallback
void HelloWorld::menuMusicCallback(CCObject* pSender)
{
CocosDenshion::SimpleAudioEngine* audio = CocosDenshion::SimpleAudioEngine::sharedEngine();
if(!audio->isBackgroundMusicPlaying())
{
audio->playBackgroundMusic("akon.mp3", true);
}
else
{
audio->stopBackgroundMusic();
}
}
示例6: removeHumanSprite
void GameScene::removeHumanSprite(HumanSprite *humanSprite)
{
if(humanSprite->humanState == 1 && humanSprite->currentY > -200)
{
GameData::gameState = GameData::STATE_GAMEOVER;
sprGameOver->setVisible(true);
CocosDenshion::SimpleAudioEngine* instance = CocosDenshion::SimpleAudioEngine::sharedEngine();
instance->stopBackgroundMusic();
this->unschedule(schedule_selector(GameScene::update));
layerCombo->setVisible(false);
if(GameData::highScore < currentScore)
{
GameData::highScore = currentScore;
FileIO::sharedInstance()->saveFile();
}
return;
}
arrayHumanSprite->removeObject(humanSprite);
this->removeChild(humanSprite, true);
}
示例7: handleFrameChanged
void CCSWFNodeExt::handleFrameChanged(cocos2d::CCObject * obj){
CCSWFNode * node = (CCSWFNode *)obj;
if (m_logicDict) {
CocosDenshion::SimpleAudioEngine * audioEngine = CocosDenshion::SimpleAudioEngine::sharedEngine();
std::stringstream frameKey;
frameKey << (node->getCurrentFrame() + 1);
CCDictionary * dict = (CCDictionary *)m_logicDict->objectForKey(frameKey.str());
if (dict) {
//切换背景音乐
CCString * music = (CCString *)dict->objectForKey("music");
if (music && m_music.compare(music->m_sString) != 0) {
m_music = music->m_sString;
if (m_music.length() > 0) {
CCLOG("CSWFNodeExt::handleFrameChanged %d playBackgroundMusic %s",node->getCurrentFrame(),m_music.c_str());
audioEngine->stopBackgroundMusic(true);
audioEngine->preloadBackgroundMusic(m_music.c_str());
audioEngine->playBackgroundMusic(m_music.c_str(),true);
}
}
//播放音效
CCString * effect = (CCString *)dict->objectForKey("effect");
if (effect && effect->length() > 0) {
const std::string tag = "#";
std::string srcString = effect->m_sString;
size_t startPos = srcString.find_first_of(tag);
if (startPos != std::string::npos) {
std::string tmp;
do {
tmp = srcString.substr(0,startPos);
CCLOG("CSWFNodeExt::handleFrameChanged %d playEffect %s",node->getCurrentFrame(),tmp.c_str());
audioEngine->preloadEffect(tmp.c_str());
audioEngine->playEffect(tmp.c_str(), false);
srcString = srcString.substr(startPos+tag.length());
startPos = srcString.find_first_of(tag);
if(startPos == std::string::npos){
CCLOG("CSWFNodeExt::handleFrameChanged %d playEffect %s",node->getCurrentFrame(),tmp.c_str());
audioEngine->preloadEffect(tmp.c_str());
audioEngine->playEffect(tmp.c_str(), false);
}
} while(startPos != std::string::npos) ;
}else{
CCLOG("CSWFNodeExt::handleFrameChanged %d playEffect %s",node->getCurrentFrame(),srcString.c_str());
audioEngine->preloadEffect(srcString.c_str());
audioEngine->playEffect(srcString.c_str(), false);
}
}
}
if (node->getCurrentFrame() == node->getFrameCount() - 1) {
audioEngine->stopAllEffects();
if (m_stopBgMusic) {
audioEngine->stopBackgroundMusic(true);
}
CCObject * effectFile = NULL;
CCARRAY_FOREACH(m_loadEffects, effectFile){
audioEngine->unloadEffect(((CCString *)effectFile)->getCString());
}
m_loadEffects->removeAllObjects();
}