A preliminary study of cocos2d-x nine

Recommended for you: Get network issues from WhatsUp Gold. Not end users.

In this article, we briefly introduce the music class, under cocos2dx SimpleAudioEngine, the game music is mainly the background music, with a short sound, OK, directly on the code:

    //Pre loading
    SimpleAudioEngine::sharedEngine()->preloadBackgroundMusic("music_logo.mp3");
    
    //Background music
    SimpleAudioEngine::sharedEngine()->playBackgroundMusic("music_logo.mp3", true);
    
    //Pause playback
    SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic();
    
    //Stop playing, and a function with one parameter, said whether to release the resource
    SimpleAudioEngine::sharedEngine()->stopBackgroundMusic();
    
    //Set the volume, 0.0-1.0
    SimpleAudioEngine::sharedEngine()->setBackgroundMusicVolume(0.5);
    
    //Play a sound
    SimpleAudioEngine::sharedEngine()->playEffect("sound_button.mp3");
    
    //Suspend a sound
    SimpleAudioEngine::sharedEngine()->pauseEffect(unsigned int nSoundId);
    
    //The suspension of all sound
    SimpleAudioEngine::sharedEngine()->pauseAllEffects();
    
    //Stop a sound
    SimpleAudioEngine::sharedEngine()->stopEffect(unsigned int nSoundId);
    
    //Stop all sound
    SimpleAudioEngine::sharedEngine()->stopAllEffects();
    
    //The program does not need to music, the release of sharedEngine()
    SimpleAudioEngine::sharedEngine()->end();

OK, So simple.~~~~

csdn

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download

Posted by Robinson at November 22, 2013 - 8:00 PM