Cocos2dx music and sound effects

Source: Internet
Author: User

// Pre-load music and sound effects

Simpleaudioengine: sharedengine ()-> preloadbackgroundmusic (ccfileutils: sharedfileutils ()-> fullpathfromrelativefile ("fashu1.wav", "fashu1.wav "));

Simpleaudioengine: sharedengine ()-> preloadeffect (ccfileutils: sharedfileutils ()-> fullpathfromrelativefile ("fashu1.wav", "fashu1.wav "));


// Set the default volume
Simpleaudioengine: sharedengine ()-> setjavastsvolume (0.5 );
Simpleaudioengine: sharedengine ()-> setbackgroundmusicvolume (0.5 );

 

// Play background music

Simpleaudioengine: sharedengine ()-> playbackgroundmusic (ccfileutils: sharedfileutils ()-> fullpathfromrelativefile ("fashu1.wav", "fashu1.wav "));

// Stop background music

Simpleaudioengine: sharedengine ()-> stopbackgroundmusic ();

// Pause background music

Simpleaudioengine: sharedengine ()-> pausebackgroundmusic ();

// Continue playing background music

Simpleaudioengine: sharedengine ()-> resumebackgroundmusic ();

// Background music

Simpleaudioengine: sharedengine ()-> rewindbackgroundmusic ();

// Whether the background music is playing

If (simpleaudioengine: sharedengine ()-> isbackgroundmusicplaying ())

{Cclog ("playing ");}

Else cclog ("not playing ");

// Play the sound and obtain the sound ID

Simpleaudioengine: sharedengine ()-> playeffect (ccfileutils: sharedfileutils ()-> fullpathfromrelativefile ("fashu1.wav", "fashu1.wav "));

// Replay sound effects

Simpleaudioengine: sharedengine ()-> playeffect (STD: string (ccfileutils: sharedfileutils ()-> fullpathfromrelativepath (music_file). c_str (), true );

// Stop Playing Sound Effects

Simpleaudioengine: sharedengine ()-> stopeffect (partition tid );

// Release sound effects

Simpleaudioengine: sharedengine ()-> unloadeffect (STD: string (ccfileutils: sharedfileutils ()-> fullpathfromrelativepath (music_file). c_str ());

// Increase the background music volume

Simpleaudioengine: sharedengine ()-> setbackgroundmusicvolume (simpleaudioengine: sharedengine ()-> getbackgroundmusicvolume () + 0.1f );

// Reduce the background music volume

Simpleaudioengine: sharedengine ()-> setbackgroundmusicvolume (simpleaudioengine: sharedengine ()-> getbackgroundmusicvolume ()-0.1f );

// Increase the background sound volume

Simpleaudioengine: sharedengine ()-> setjavastsvolume (simpleaudioengine: sharedengine ()-> getjavastsvolume () + 0.1f );

// Reduce the background sound volume

Simpleaudioengine: sharedengine ()-> setjavastsvolume (simpleaudioengine: sharedengine ()-> getjavastsvolume ()-0.1f );

// Pause the sound effect

Simpleaudioengine: sharedengine ()-> pauseeffect (partition tid );

// Resume the sound effect

Simpleaudioengine: sharedengine ()-> resumeeffect (partition tid );

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.