Cocos2d-Sound API

Source: Internet
Author: User

Play background music

@param {String} URL sound path

@param {Boolean} loop is played back

Cc.audioEngine.playMusic (URL, loop);

Stop background music

@param {Boolean} releasedata whether to release sound data, default to False

Cc.audioEngine.stopMusic (Releasedata);

Pause background music

Cc.audioEngine.pauseMusic ();

Restore background music

Cc.audioEngine.resumeMusic ();

Re-play background music

Cc.audioEngine.rewindMusic ();

Get background music Volume

The value of @return {number} is between 0 and 1.0

Cc.audioEngine.getMusicVolume ();

Set background music volume

@param {Number} volume range 0.0~1.0.

Cc.audioEngine.setMusicVolume (volume);

Gets whether the background music is in play

@return {Boolean} is playing back true, otherwise returns false

Cc.audioEngine.isMusicPlaying ();

Play sound (basically similar to music)

@param {String} URL sound file path

@param {Boolean} loop plays, default value is False

@return {Number|null} returns the sound ID

Audioid cc.audioEngine.playEffect (URL, loop);

Get Sound Volume

Cc.audioEngine.getEffectsVolume ();

Set Sound volume

Cc.audioEngine.setEffectsVolume (volume);

Pause the corresponding sound

Cc.audioEngine.pauseEffect (audioid);

Pause all sound effects

Cc.audioEngine.pauseAllEffects ();

Restore the corresponding sound effects

Cc.audioEngine.resumeEffect (audioid);

Restore all sound effects

Cc.audioEngine.resumeAllEffects ();

Stop the corresponding sound

Cc.audioEngine.stopEffect (audioid);

Unload sound data in a memory buffer

Cc.audioEngine.unloadEffect (URL);

The difference between game sound and game music:

Game sound generally refers to a particular action in the game or play a specific operation of the music, such as gunfire, the game of bullets in the launch of the sound, or the role-playing game monster killed when the scream.

There are three categories of game sounds, namely:

Mono sound, most of the sound in the game is mono sound;

Composite sound generally refers to a plurality of sound elements, in the course of the game by the program in real time to synthesize the sound effects of these reasons;

Musical sound generally refers to a piece of music, usually the player enters the map at that moment of music, this music is generally belong to the music production extend.

So what's the difference between game sound and game music? Game music generally refers to the game in the continuous play of background music, usually with the game operation and the state of the game is irrelevant, while the game sound is generally the game in particular scenes and behavior triggered by the music, if not triggered does not play

Cocos2d-Sound API

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.