本文整理汇总了C++中cocosdenshion::SimpleAudioEngine::setBackgroundMusicVolume方法的典型用法代码示例。如果您正苦于以下问题:C++ SimpleAudioEngine::setBackgroundMusicVolume方法的具体用法?C++ SimpleAudioEngine::setBackgroundMusicVolume怎么用?C++ SimpleAudioEngine::setBackgroundMusicVolume使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cocosdenshion::SimpleAudioEngine
的用法示例。
在下文中一共展示了SimpleAudioEngine::setBackgroundMusicVolume方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: lua_cocos2dx_cocosdenshion_SimpleAudioEngine_setBackgroundMusicVolume
int lua_cocos2dx_cocosdenshion_SimpleAudioEngine_setBackgroundMusicVolume(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_setBackgroundMusicVolume'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 1)
{
double arg0;
ok &= luaval_to_number(tolua_S, 2,&arg0, "cc.SimpleAudioEngine:setBackgroundMusicVolume");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_cocosdenshion_SimpleAudioEngine_setBackgroundMusicVolume'", nullptr);
return 0;
}
cobj->setBackgroundMusicVolume(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:setBackgroundMusicVolume",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_cocosdenshion_SimpleAudioEngine_setBackgroundMusicVolume'.",&tolua_err);
#endif
return 0;
}