本文整理汇总了C++中cocosdenshion::SimpleAudioEngine类的典型用法代码示例。如果您正苦于以下问题:C++ SimpleAudioEngine类的具体用法?C++ SimpleAudioEngine怎么用?C++ SimpleAudioEngine使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SimpleAudioEngine类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:kiyanty,项目名称:SoloManse,代码行数:29,代码来源:GameScene.cpp
示例2: onPlay
void MainLayer::onPlay(CCObject* pSender)
{
CocosDenshion::SimpleAudioEngine *audioEngine = CocosDenshion::SimpleAudioEngine::sharedEngine();
audioEngine->playBackgroundMusic("background.mp3",true);
CCDirector::sharedDirector()->replaceScene(PlayLayer::scene());
}
开发者ID:HScarb,项目名称:SK_Parkour,代码行数:7,代码来源:MainScene.cpp
示例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;
}
开发者ID:footprint,项目名称:quick-3.3,代码行数:59,代码来源:lua_cocos2dx_cocosdenshion_auto.cpp
示例4: clickBtnResume
void GameScene::clickBtnResume(CCObject* pObject)
{
layerPauseMenu->setVisible(false);
GameData::gameState = GameData::STATE_PLAYING;
CocosDenshion::SimpleAudioEngine* instance = CocosDenshion::SimpleAudioEngine::sharedEngine();
instance->resumeBackgroundMusic();
}
开发者ID:kiyanty,项目名称:SoloManse,代码行数:8,代码来源:GameScene.cpp
示例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;
}
开发者ID:kiyanty,项目名称:SoloManse,代码行数:9,代码来源:GameScene.cpp
示例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");
}
开发者ID:LiYuandong,项目名称:Parkour,代码行数:10,代码来源:Runner.cpp
示例7: startBackgroundMusic
void GameScene::startBackgroundMusic()
{
CocosDenshion::SimpleAudioEngine* instance = CocosDenshion::SimpleAudioEngine::sharedEngine();
instance->stopBackgroundMusic();
if(GameData::isMusicSound)
{
instance->playBackgroundMusic("game.wav", true);
}
}
开发者ID:kiyanty,项目名称:SoloManse,代码行数:11,代码来源:GameScene.cpp
示例8: menuMusicCallback
void HelloWorld::menuMusicCallback(CCObject* pSender)
{
CocosDenshion::SimpleAudioEngine* audio = CocosDenshion::SimpleAudioEngine::sharedEngine();
if(!audio->isBackgroundMusicPlaying())
{
audio->playBackgroundMusic("akon.mp3", true);
}
else
{
audio->stopBackgroundMusic();
}
}
开发者ID:dimasv28,项目名称:noob,代码行数:12,代码来源:HelloWorldScene.cpp
示例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");
}
}
开发者ID:LiYuandong,项目名称:Parkour,代码行数:13,代码来源:Runner.cpp
示例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;
}
开发者ID:footprint,项目名称:quick-3.3,代码行数:50,代码来源:lua_cocos2dx_cocosdenshion_auto.cpp
示例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();
}
开发者ID:kiyanty,项目名称:SoloManse,代码行数:14,代码来源:GameScene.cpp
示例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;
}
开发者ID:2016Go,项目名称:TF2016-NEW,代码行数:50,代码来源:lua_cocos2dx_cocosdenshion_auto.cpp
示例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;
}
开发者ID:2016Go,项目名称:TF2016-NEW,代码行数:47,代码来源:lua_cocos2dx_cocosdenshion_auto.cpp
示例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;
}
开发者ID:HScarb,项目名称:SK_Parkour,代码行数:35,代码来源:MainScene.cpp
示例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);
}
开发者ID:kiyanty,项目名称:SoloManse,代码行数:24,代码来源:GameScene.cpp
示例16: 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();
}
开发者ID:lkeplei,项目名称:QeeQoo,代码行数:61,代码来源:CCSWFNodeExt.cpp
示例17: lua_cocos2dx_cocosdenshion_SimpleAudioEngine_playEffect
int lua_cocos2dx_cocosdenshion_SimpleAudioEngine_playEffect(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_playEffect'", 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:playEffect"); arg0 = arg0_tmp.c_str();
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_cocosdenshion_SimpleAudioEngine_playEffect'", nullptr);
return 0;
}
unsigned int ret = cobj->playEffect(arg0);
tolua_pushnumber(tolua_S,(lua_Number)ret);
return 1;
}
if (argc == 2)
{
const char* arg0;
bool arg1;
std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "cc.SimpleAudioEngine:playEffect"); arg0 = arg0_tmp.c_str();
ok &= luaval_to_boolean(tolua_S, 3,&arg1, "cc.SimpleAudioEngine:playEffect");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_cocosdenshion_SimpleAudioEngine_playEffect'", nullptr);
return 0;
}
unsigned int ret = cobj->playEffect(arg0, arg1);
tolua_pushnumber(tolua_S,(lua_Number)ret);
return 1;
}
if (argc == 3)
{
const char* arg0;
bool arg1;
double arg2;
std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "cc.SimpleAudioEngine:playEffect"); arg0 = arg0_tmp.c_str();
ok &= luaval_to_boolean(tolua_S, 3,&arg1, "cc.SimpleAudioEngine:playEffect");
ok &= luaval_to_number(tolua_S, 4,&arg2, "cc.SimpleAudioEngine:playEffect");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_cocosdenshion_SimpleAudioEngine_playEffect'", nullptr);
return 0;
}
unsigned int ret = cobj->playEffect(arg0, arg1, arg2);
tolua_pushnumber(tolua_S,(lua_Number)ret);
return 1;
}
if (argc == 4)
{
const char* arg0;
bool arg1;
double arg2;
double arg3;
std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "cc.SimpleAudioEngine:playEffect"); arg0 = arg0_tmp.c_str();
ok &= luaval_to_boolean(tolua_S, 3,&arg1, "cc.SimpleAudioEngine:playEffect");
ok &= luaval_to_number(tolua_S, 4,&arg2, "cc.SimpleAudioEngine:playEffect");
ok &= luaval_to_number(tolua_S, 5,&arg3, "cc.SimpleAudioEngine:playEffect");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_cocosdenshion_SimpleAudioEngine_playEffect'", nullptr);
return 0;
}
unsigned int ret = cobj->playEffect(arg0, arg1, arg2, arg3);
tolua_pushnumber(tolua_S,(lua_Number)ret);
return 1;
}
//.........这里部分代码省略.........
开发者ID:2016Go,项目名称:TF2016-NEW,代码行数:101,代码来源:lua_cocos2dx_cocosdenshion_auto.cpp
示例18: generateLevel
Scene* SceneManager::generateLevel(int levelIndex, int score)
{
if (levelIndex == 0) {
Director* director = Director::getInstance();
float height = director->getWinSize().height;
float width = director->getWinSize().width;
// Create start scene
ParallaxBackground* bckMenu = new ParallaxBackground();
bckMenu->addImage("night.png", Vec2(width / 2, height / 1.3), Vec2(0.05, 0));
bckMenu->addImage("city.png", Vec2(width / 2, height / 1.6), Vec2(0.3, 0));
bckMenu->addImage("street.png", Vec2(width / 2, height / 2.6), Vec2(1.0, 0), true);
bckMenu->scheduleUpdate();
auto startScene = IntermediaryScene::create(IntermediaryScene::MENU);
startScene->setBackground(bckMenu);
// Create dummy player
auto dummy = DummyPlayer::create();
dummy->setPosition(Vec2(width / 2, 130));
startScene->setPlayer(dummy);
// Create music
CocosDenshion::SimpleAudioEngine* audioEngine = CocosDenshion::SimpleAudioEngine::getInstance();
audioEngine->playBackgroundMusic("level0.mp3", true);
Label* playButtonLabel = Label::createWithTTF("Play", "font.ttf", 35);
MenuItem* playButton = MenuItemLabel::create(playButtonLabel, [&](Ref* sender){SceneManager::getInstance().fillStack();});
Label* optionsButtonLabel = Label::createWithTTF("Options", "font.ttf", 35);
MenuItem* optionsButton = MenuItemLabel::create(optionsButtonLabel);
Label* exitButtonLabel = Label::createWithTTF("Exit", "font.ttf", 35);
MenuItem* exitButton = MenuItemLabel::create(exitButtonLabel, [&](Ref* sender){Director::getInstance()->end(); });
startScene->addMenuItem(playButton);
startScene->addMenuItem(optionsButton);
startScene->addMenuItem(exitButton);
startScene->createMenu();
return startScene;
}
if (levelIndex == 1) {
Director* director = Director::getInstance();
// Create a new GameLayer
GameLayer* firstLevelLayer = GameLayer::create();
// Create a background
ParallaxBackground* bckFirstLevel = new ParallaxBackground();
float height = director->getWinSize().height;
float width = director->getWinSize().width;
// Create animations and bullets
bckFirstLevel->addImage("night.png", Vec2(width / 2, height / 1.3), Vec2(0.05, 0));
bckFirstLevel->addImage("city.png", Vec2(width / 2, height / 1.6), Vec2(0.3, 0));
bckFirstLevel->addImage("street.png", Vec2(width / 2, height / 2.6), Vec2(1.0, 0),true);
bckFirstLevel->scheduleUpdate();
// Create music
CocosDenshion::SimpleAudioEngine* audioEngine = CocosDenshion::SimpleAudioEngine::getInstance();
audioEngine->playBackgroundMusic("level1.mp3", true);
// Create player
Player* hero = Player::create();
hero->setPosition(Vec2(width / 2, 130));
hero->setTag(PLAYER_TAG);
hero->setScore(score);
// Create boss
Boss* boss = Boss::create(OBJECT_FIRSTBOSS);
BossCannon* cannon1 = BossCannon::create(OBJECT_FIRSTBOSS_CANNON_1, OBJECT_FIRSTBOSS_CANNON_1_D, OBJECT_BOSSBULLET_LASER);
cannon1->setPosition(Vec2(123, 105));
cannon1->setFireMethod(1, 10, 50);
BossCannon* cannon2 = BossCannon::create(OBJECT_FIRSTBOSS_CANNON_2, OBJECT_FIRSTBOSS_CANNON_2_D, OBJECT_BOSSBULLET_SPIKEBALL);
cannon2->setPosition(Vec2(150, 183));
cannon2->setFireMethod(2, 10, 50);
BossCannon* cannon3 = BossCannon::create(OBJECT_FIRSTBOSS_CANNON_3, OBJECT_FIRSTBOSS_CANNON_3_D, OBJECT_BOSSBULLET_BALL);
cannon3->setPosition(Vec2(59, 148));
cannon3->setFireMethod(3, 3, 50);
boss->addCannon(1, cannon2);
boss->addCannon(2, cannon1);
boss->addCannon(3, cannon3);
// Create Interactive object factory
InteractiveObjectFactory* mailboxFactory = InteractiveObjectFactory::create(OBJECT_MAILBOX, director->getWinSize().height * 1.6 / 800, false, MAILBOX_COLLISION_BITMASK, true, false, true);
mailboxFactory->setPositionInterval(Vec2(height / GROUND_PERCENTAGE_FOR_BOX + 10, height / GROUND_PERCENTAGE_FOR_BOX + 10));
mailboxFactory->setSpawnFrequency(5);
mailboxFactory->setSpeed(Vec2(-(Director::getInstance()->getWinSize().width * 10.0 / 800), 0));
InteractiveObjectFactory* rocketFactory = InteractiveObjectFactory::create(OBJECT_ROCKET, director->getWinSize().height * 1.6 / 800, false, ROCKET_COLLISION_BITMASK, true, false, false);
rocketFactory->setPositionInterval(Vec2(100, height));
rocketFactory->setSpeed(Vec2(-(Director::getInstance()->getWinSize().width * 25.0 / 800), 0));
rocketFactory->setSpawnFrequency(20);
//.........这里部分代码省略.........
开发者ID:Totolin,项目名称:cultus-cocos2d,代码行数:101,代码来源:SceneManager.cpp
示例19: preload_sounds
void AppDelegate::preload_sounds()
{
#ifdef _WIN32
CCLOG("on windows, skipping audio preload");
#else
CocosDenshion::SimpleAudioEngine* cache = CocosDenshion::SimpleAudioEngine::getInstance();
CCLOG("start loading audio");
cache->preloadEffect(clean_path("sounds\\old\\Swoosh.mp3").c_str());
cache->preloadEffect(clean_path("sounds\\old\\barrel.mp3").c_str());
cache->preloadEffect(clean_path("sounds\\old\\beep.mp3").c_str());
// cache->preloadEffect(clean_path("sounds\\old\\block.mp3").c_str());
cache->preloadEffect(clean_path("sounds\\old\\brick_hit.mp3").c_str());
cache->preloadEffect(clean_path("sounds\\old\\brick_scrape.mp3").c_str());
cache->preloadEffect(clean_path("sounds\\old\\cheering.mp3").c_str());
cache->preloadEffect(clean_path("sounds\\old\\coin.mp3").c_str());
//cache->preloadEffect(clean_path("sounds\\old\\ding.mp3").c_str());
cache->preloadEffect(clean_path("sounds\\old\\doom_rocket.mp3").c_str());
cache->preloadEffect(clean_path("sounds\\old\\dsnoway.mp3").c_str());
cache->preloadEffect(clean_path("sounds\\old\\glassbreak.mp3").c_str());
cache->preloadEffect(clean_path("sounds\\old\\ice_freeze.mp3").c_str());
//cache->preloadEffect(clean_path("sounds\\old\\lighter.mp3").c_str());
cache->preloadEffect(clean_path("sounds\\old\\radio_wave.mp3").c_str());
cache->preloadEffect(clean_path("sounds\\old\\real_punch.mp3").c_str());
cache->preloadEffect(clean_path("sounds\\old\\shield_die.mp3").c_str());
cache->preloadEffect(clean_path("sounds\\old\\shield_disable.mp3").c_str());
cache->preloadEffect(clean_path("sounds\\old\\shield_hit.mp3").c_str());
cache->preloadEffect(clean_path("sounds\\old\\shotgun.mp3").c_str());
cache->preloadEffect(clean_path("sounds\\old\\shotgun_reload.mp3").c_str());
cache->preloadEffect(clean_path("sounds\\old\\suicide_bomber.mp3").c_str());
cache->preloadEffect(clean_path("sounds\\old\\wall_destroy.mp3").c_str());
cache->preloadEffect(clean_path("sounds\\new\\barrel\\C_barrel_1.mp3").c_str());
cache->preloadEffect(clean_path("sounds\\new\\block\\C_block+1.mp3").c_str());
// cache->preloadEffect(clean_path("sounds\\new\\block\\C_block+2.mp3").c_str());
// cache->preloadEffect(clean_path("sounds\\new\\block\\C_block_1.mp3").c_str());
cache->preloadEffect(clean_path("sounds\\new\\charged\\C_charged_1.mp3").c_str());
//cache->preloadEffect(clean_path("sounds\\new\\cheering\\C_cheering_11.mp3").c_str()); //TODO Find a use for this
//cache->preloadEffect(clean_path("sounds\\new\\cheering\\C_cheering_12.mp3").c_str()); //TODO Find a use for this
cache->preloadEffect(clean_path("sounds\\new\\cheering\\C_cheering_13.mp3").c_str());
//cache->preloadEffect(clean_path("sounds\\new\\coin\\C_coin_1.mp3").c_str());
//cache->preloadEffect(clean_path("sounds\\new\\coin\\C_coin_2.mp3").c_str());
cache->preloadEffect(clean_path("sounds\\new\\doom_rocket\\C_grenade_1.mp3").c_str());
cache->preloadEffect(clean_path("sounds\\new\\doom_rocket\\C_rocket_big_1.mp3").c_str());
cache->preloadEffect(clean_path("sounds\\new\\doom_rocket\\C_rocket_small_1.mp3").c_str());
cache->preloadEffect(clean_path("sounds\\new\\dsnoway\\C_Grunt_11.mp3").c_str());
cache->preloadEffect(clean_path("sounds\\new\\dsnoway\\C_Grunt_12.mp3").c_str());
cache->preloadEffect(clean_path("sounds\\new\\dsnoway\\C_Grunt_13.mp3").c_str());
cache->preloadEffect(clean_path("sounds\\new\\dsnoway\\C_Grunt_14.mp3").c_str());
cache->preloadEffect(clean_path("sounds\\new\\dsnoway\\C_Grunt_15.mp3").c_str());
cache->preloadEffect(clean_path("sounds\\new\\dsnoway\\C_Grunt_16.mp3").c_str());
cache->preloadEffect(clean_path("sounds\\new\\dsnoway\\C_Grunt_17.mp3").c_str());
cache->preloadEffect(clean_path("sounds\\new\\dsnoway\\C_Grunt_18.mp3").c_str());
cache->preloadEffect(clean_path("sounds\\new\\dsnoway\\C_Hit_11.mp3").c_str());
cache->preloadEffect(clean_path("sounds\\new\\dsnoway\\C_Hit_12.mp3").c_str());
cache->preloadEffect(clean_path("sounds\\new\\dsnoway\\C_Hit_13.mp3").c_str());
cache->preloadEffect(clean_path("sounds\\new\\dsnoway\\C_Hit_14.mp3").c_str());
cache->preloadEffect(clean_path("sounds\\new\\dsnoway\\C_Hit_15.mp3").c_str());
cache->preloadEffect(clean_path("sounds\\new\\dsnoway\\C_Hit_16.mp3").c_str());
cache->preloadEffect(clean_path("sounds\\new\\dsnoway\\C_Hit_17.mp3").c_str());
cache->preloadEffect(clean_path("sounds\\new\\dsnoway\\C_Hit_18.mp3").c_str());
cache->preloadEffect(clean_path("sounds\\new\\extra\\C_explosion_1.mp3").c_str());
cache->preloadEffect(clean_path("sounds\\new\\glassbreak\\C_glassbreak_1.mp3").c_str());
cache->preloadEffect(clean_path("sounds\\new\\ice_freeze\\C_ice_freeze+.mp3").c_str());
cache->preloadEffect(clean_path("sounds\\new\\ice_freeze\\C_ice_freeze_1.mp3").c_str());
cache->preloadEffect(clean_path("sounds\\new\\lighter\\C_lighter_1.mp3").c_str());
cache->preloadEffect(clean_path("sounds\\new\\radio_wave\\C_radio_wave_1.mp3").c_str());
cache->preloadEffect(clean_path("sounds\\new\\radio_wave\\C_radio_wave_2.mp3").c_str());
cache->preloadEffect(clean_path("sounds\\new\\radio_wave\\C_radio_wave_3.mp3").c_str());
cache->preloadEffect(clean_path("sounds\\new\\real_punch\\C_combo_1.mp3").c_str());
cache->preloadEffect(clean_path("sounds\\new\\real_punch\\C_punch+1.mp3").c_str());
cache->preloadEffect(clean_path("sounds\\new\\real_punch\\C_punch+2.mp3").c_str());
cache->preloadEffect(clean_path("sounds\\new\\real_punch\\C_punch+3.mp3").c_str());
cache->preloadEffect(clean_path("sounds\\new\\real_punch\\C_punch_11.mp3").c_str());
cache->preloadEffect(clean_path("sounds\\new\\real_punch\\C_punch_21.mp3").c_str());
cache->preloadEffect(clean_path("sounds\\new\\real_punch\\C_punch_22.mp3").c_str());
cache->preloadEffect(clean_path("sounds\\new\\real_punch\\C_punch_23.mp3").c_str());
cache->preloadEffect(clean_path("sounds\\new\\real_punch\\C_punch_24.mp3").c_str());
cache->preloadEffect(clean_path("sounds\\new\\real_punch\\C_punch_25.mp3").c_str());
// cache->preloadEffect(clean_path("sounds\\new\\real_punch\\C_punch_26.mp3").c_str());
cache->preloadEffect(clean_path("sounds\\new\\real_punch\\C_punch_27.mp3").c_str());
cache->preloadEffect(clean_path("sounds\\new\\real_punch\\C_punch_28.mp3").c_str());
cache->preloadEffect(clean_path("sounds\\new\\real_punch\\C_punch_31.mp3").c_str());
cache->preloadEffect(clean_path("sounds\\new\\shotgun\\C_shotgun_1.mp3").c_str());
cache->preloadEffect(clean_path("sounds\\new\\shotgun_reload\\C_shotgun_reload_1.mp3").c_str());
cache->preloadEffect(clean_path("sounds\\new\\suicide_bomber\\C_rocket_big+1.mp3").c_str());
cache->preloadEffect(clean_path("sounds\\new\\suicide_bomber\\C_rocket_small+2.mp3").c_str());
cache->preloadEffect(clean_path("sounds\\new\\Swoosh\\C_Swoosh_1.wav").c_str());
cache->preloadEffect(clean_path("sounds\\new\\Swoosh\\C_Swoosh_11.mp3").c_str());
cache->preloadEffect(clean_path("sounds\\new\\Swoosh\\C_Swoosh_12.mp3").c_str());
cache->preloadEffect(clean_path("sounds\\new\\Swoosh\\C_Swoosh_13.mp3").c_str());
cache->preloadEffect(clean_path("sounds\\new\\Swoosh\\C_Swoosh_14.mp3").c_str());
cache->preloadEffect(clean_path("sounds\\new\\Swoosh\\C_Swoosh_15.mp3").c_str());
cache->preloadEffect(clean_path("sounds\\new\\Swoosh\\C_Swoosh_21.mp3").c_str());
cache->preloadEffect(clean_path("sounds\\new\\Swoosh\\C_Swoosh_22.mp3").c_str());
cache->preloadEffect(clean_path("sounds\\new\\Swoosh\\C_Swoosh_23.mp3").c_str());
cache->preloadEffect(clean_path("sounds\\new\\Swoosh\\C_Swoosh_24.mp3").c_str());
cache->preloadEffect(clean_path("sounds\\new\\Swoosh\\C_Swoosh_25.mp3").c_str());
cache->preloadEffect(clean_path("sounds\\new\\Swoosh\\C_Swoosh_26.mp3").c_str());
//.........这里部分代码省略.........
开发者ID:tankorsmash,项目名称:BeatupTheFace,代码行数:101,代码来源:AppDelegate.cpp
注:本文中的cocosdenshion::SimpleAudioEngine类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论