Skip to content

Commit

Permalink
Added different Music tracks for menu and each level
Browse files Browse the repository at this point in the history
  • Loading branch information
German Torres committed Apr 21, 2017
1 parent 5fa119e commit 57eb8df
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 6 deletions.
9 changes: 8 additions & 1 deletion Classes/MarsScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ bool Mars::init()
}
auto cache = SpriteFrameCache::getInstance();
cache->addSpriteFramesWithFile("mars.plist");
cache->addSpriteFramesWithFile("marsTips.plist");
setupAudio();
return true;
}

Expand All @@ -41,6 +41,13 @@ void Mars::loadMap()
GameMap::loadMap();
}

void Mars::setupAudio()
{
auto audio = SimpleAudioEngine::getInstance();
audio->stopBackgroundMusic();
audio->playBackgroundMusic("sfx/marsMusic.mp3", true);
}

void Mars::setupBackground()
{
dust = ParticleRain::create();
Expand Down
7 changes: 2 additions & 5 deletions Classes/MenugScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,8 @@ void Menug::loadAudio()
{
auto audio = SimpleAudioEngine::getInstance();
audio->preloadEffect("sfx/button.wav");
if (!audio->isBackgroundMusicPlaying())
{
audio->stopBackgroundMusic();
audio->playBackgroundMusic("sfx/marsMusic.mp3", true);
}
audio->stopBackgroundMusic();
audio->playBackgroundMusic("sfx/introMusic.mp3", true);
}

void Menug::cacheImages()
Expand Down
8 changes: 8 additions & 0 deletions Classes/UranusScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,17 @@ void Uranus::loadMap()
setupBackground();
setupParallaxImages();
setupSpikes();
setupAudio();
GameMap::loadMap();
}

void Uranus::setupAudio()
{
auto audio = SimpleAudioEngine::getInstance();
audio->stopBackgroundMusic();
audio->playBackgroundMusic("sfx/uranusMusic.mp3",true);
}

void Uranus::setupBackground()
{
auto bgSprite = Sprite::createWithSpriteFrameName("bg.png");
Expand Down
Binary file added Resources/sfx/introMusic.mp3
Binary file not shown.
Binary file added Resources/sfx/uranusMusic.mp3
Binary file not shown.

0 comments on commit 57eb8df

Please sign in to comment.