本文整理汇总了C++中cocosdenshion::SimpleAudioEngine类的典型用法代码示例。如果您正苦于以下问题:C++ SimpleAudioEngine类的具体用法?C++ SimpleAudioEngine怎么用?C++ SimpleAudioEngine使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SimpleAudioEngine类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: onPlay
void MainLayer::onPlay(CCObject* pSender)
{
CocosDenshion::SimpleAudioEngine *audioEngine = CocosDenshion::SimpleAudioEngine::sharedEngine();
audioEngine->playBackgroundMusic("background.mp3",true);
CCDirector::sharedDirector()->replaceScene(PlayLayer::scene());
}
示例3: 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;
}
示例4: clickBtnResume
void GameScene::clickBtnResume(CCObject* pObject)
{
layerPauseMenu->setVisible(false);
GameData::gameState = GameData::STATE_PLAYING;
CocosDenshion::SimpleAudioEngine* instance = CocosDenshion::SimpleAudioEngine::sharedEngine();
instance->resumeBackgroundMusic();
}
示例5: 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;
}
示例6: crouch
void Runner::crouch()
{
m_state = RunnerStateCrouch;
this->initShape("crouch");
this->stopAllActions();
this->runAction(m_actionCrouch);
this->scheduleOnce(schedule_selector(Runner::loadNormal), 1.5);
CocosDenshion::SimpleAudioEngine *audioEngine = CocosDenshion::SimpleAudioEngine::sharedEngine();
audioEngine->playEffect("Sound/crouch.mp3");
}
示例7: startBackgroundMusic
void GameScene::startBackgroundMusic()
{
CocosDenshion::SimpleAudioEngine* instance = CocosDenshion::SimpleAudioEngine::sharedEngine();
instance->stopBackgroundMusic();
if(GameData::isMusicSound)
{
instance->playBackgroundMusic("game.wav", true);
}
}
示例8: menuMusicCallback
void HelloWorld::menuMusicCallback(CCObject* pSender)
{
CocosDenshion::SimpleAudioEngine* audio = CocosDenshion::SimpleAudioEngine::sharedEngine();
if(!audio->isBackgroundMusicPlaying())
{
audio->playBackgroundMusic("akon.mp3", true);
}
else
{
audio->stopBackgroundMusic();
}
}
示例9: jump
void Runner::jump()
{
if (m_state == RunnerStateRunning)
{
m_state = RunnerStateJumpUp;
cpBodyApplyImpulse(body, cpv(0, 400), cpv(0, 0));
this->stopAllActions();
this->runAction(m_actionJumpUp);
CocosDenshion::SimpleAudioEngine *audioEngine = CocosDenshion::SimpleAudioEngine::sharedEngine();
audioEngine->playEffect("Sound/jump.mp3");
}
}
示例10: lua_cocos2dx_cocosdenshion_SimpleAudioEngine_getDuration
int lua_cocos2dx_cocosdenshion_SimpleAudioEngine_getDuration(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_getDuration'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 1)
{
const char* arg0;
std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "cc.SimpleAudioEngine:getDuration"); arg0 = arg0_tmp.c_str();
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_cocosdenshion_SimpleAudioEngine_getDuration'", nullptr);
return 0;
}
double ret = cobj->getDuration(arg0);
tolua_pushnumber(tolua_S,(lua_Number)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.SimpleAudioEngine:getDuration",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_cocosdenshion_SimpleAudioEngine_getDuration'.",&tolua_err);
#endif
return 0;
}
示例11: clickBtnPause
void GameScene::clickBtnPause(CCObject* pOjbect)
{
// initMenuItemBtnPause();
if(GameData::gameState == GameData::STATE_GAMEOVER)
{
return;
}
startSoundEffect("pong.wav");
GameData::gameState = GameData::STATE_PAUSE;
layerPauseMenu->setVisible(true);
CocosDenshion::SimpleAudioEngine* instance = CocosDenshion::SimpleAudioEngine::sharedEngine();
instance->pauseBackgroundMusic();
}
示例12: lua_cocos2dx_cocosdenshion_SimpleAudioEngine_pauseEffect
int lua_cocos2dx_cocosdenshion_SimpleAudioEngine_pauseEffect(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_pauseEffect'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 1)
{
unsigned int arg0;
ok &= luaval_to_uint32(tolua_S, 2,&arg0, "cc.SimpleAudioEngine:pauseEffect");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_cocosdenshion_SimpleAudioEngine_pauseEffect'", nullptr);
return 0;
}
cobj->pauseEffect(arg0);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.SimpleAudioEngine:pauseEffect",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_cocosdenshion_SimpleAudioEngine_pauseEffect'.",&tolua_err);
#endif
return 0;
}
示例13: lua_cocos2dx_cocosdenshion_SimpleAudioEngine_getEffectsVolume
int lua_cocos2dx_cocosdenshion_SimpleAudioEngine_getEffectsVolume(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_getEffectsVolume'", 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_getEffectsVolume'", nullptr);
return 0;
}
double ret = cobj->getEffectsVolume();
tolua_pushnumber(tolua_S,(lua_Number)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.SimpleAudioEngine:getEffectsVolume",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_cocosdenshion_SimpleAudioEngine_getEffectsVolume'.",&tolua_err);
#endif
return 0;
}
示例14: init
bool MainLayer::init()
{
if (!CCLayer::init()) {
return false;
}
CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();
CCPoint centerPos = CCPoint(visibleSize.width / 2, visibleSize.height / 2);
//add backgroud
CCSprite *spriteBG = CCSprite::create("MainBG.png");
spriteBG->setPosition(ccp(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y));
this->addChild(spriteBG, 0);
//add menu item
CCMenuItemFont::setFontSize(60);
CCMenuItemImage *menuItemPlay = CCMenuItemImage::create("start_n.png", "start_s.png", this, menu_selector(MainLayer::onPlay));
menuItemPlay->setPosition(centerPos);
// create menu, it's an autorelease object
CCMenu* pMenu = CCMenu::create(menuItemPlay, NULL);
pMenu->setPosition(CCPointZero);
this->addChild(pMenu, 1);
// preload music
CocosDenshion::SimpleAudioEngine *audioEngine = CocosDenshion::SimpleAudioEngine::sharedEngine();
audioEngine->preloadBackgroundMusic("background.mp3");
audioEngine->preloadEffect("jump.mp3");
audioEngine->preloadEffect("crouch.mp3");
audioEngine->setBackgroundMusicVolume(0.3);
audioEngine->setEffectsVolume(0.3);
return true;
}
示例15: 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);
}