Skip to main content
added 692 characters in body
Source Link
Jasmine
  • 188
  • 6

in Cocos2D, doesn't the music continue to play until you pause or stop it?

If I want to change music between CCScene I usually do something like:

_dir->Instance()->getAudioEngine()->stopBackgroundMusic();
_dir->Instance()->getAudioEngine()->stopAllEffects();

// click!
_dir->Instance()->getAudioEngine()->playEffect("click.mp3", false);

...do whatever

Edit:

I dont use the shared director. I created my own director object with everything I need as member variables.

I load my music like this:

void AppDirector::createAudioEngine()
{
    CocosDenshion::SimpleAudioEngine* ae = new CocosDenshion::SimpleAudioEngine();

    ae->preloadBackgroundMusic("Tallahassee.mp3");
    ae->preloadBackgroundMusic("bigcountry.mp3");

    ae->preloadEffect("click.mp3");
    ae->preloadEffect("tap.mp3");

    ae->setBackgroundMusicVolume(0.5f);
    ae->setEffectsVolume(0.3f);

    setAudioEngine(ae);
}

Edit 2:

I do this:

AppDirector* AppDirector::Instance()
{
    if (pinstance == 0) // is it the first call?
    {
        pinstance = new AppDirector; // create sole instance
        pinstance->initInstance(); // setup everything we need.
    }

     return pinstance; // address of sole instance
}

void AppDirector::initInstance()
{
    createFileUtils();

    createDirector();

    // set some defaults
    setIsHUDDisplayed(false);

    createTouchDispatcher();

    createAudioEngine(); // created and preloads music and sound effects.

    createOpeningScene();
}

in Cocos2D, doesn't the music continue to play until you pause or stop it?

If I want to change music between CCScene I usually do something like:

_dir->Instance()->getAudioEngine()->stopBackgroundMusic();
_dir->Instance()->getAudioEngine()->stopAllEffects();

// click!
_dir->Instance()->getAudioEngine()->playEffect("click.mp3", false);

...do whatever

Edit:

I dont use the shared director. I created my own director object with everything I need as member variables.

I load my music like this:

void AppDirector::createAudioEngine()
{
    CocosDenshion::SimpleAudioEngine* ae = new CocosDenshion::SimpleAudioEngine();

    ae->preloadBackgroundMusic("Tallahassee.mp3");
    ae->preloadBackgroundMusic("bigcountry.mp3");

    ae->preloadEffect("click.mp3");
    ae->preloadEffect("tap.mp3");

    ae->setBackgroundMusicVolume(0.5f);
    ae->setEffectsVolume(0.3f);

    setAudioEngine(ae);
}

in Cocos2D, doesn't the music continue to play until you pause or stop it?

If I want to change music between CCScene I usually do something like:

_dir->Instance()->getAudioEngine()->stopBackgroundMusic();
_dir->Instance()->getAudioEngine()->stopAllEffects();

// click!
_dir->Instance()->getAudioEngine()->playEffect("click.mp3", false);

...do whatever

Edit:

I dont use the shared director. I created my own director object with everything I need as member variables.

I load my music like this:

void AppDirector::createAudioEngine()
{
    CocosDenshion::SimpleAudioEngine* ae = new CocosDenshion::SimpleAudioEngine();

    ae->preloadBackgroundMusic("Tallahassee.mp3");
    ae->preloadBackgroundMusic("bigcountry.mp3");

    ae->preloadEffect("click.mp3");
    ae->preloadEffect("tap.mp3");

    ae->setBackgroundMusicVolume(0.5f);
    ae->setEffectsVolume(0.3f);

    setAudioEngine(ae);
}

Edit 2:

I do this:

AppDirector* AppDirector::Instance()
{
    if (pinstance == 0) // is it the first call?
    {
        pinstance = new AppDirector; // create sole instance
        pinstance->initInstance(); // setup everything we need.
    }

     return pinstance; // address of sole instance
}

void AppDirector::initInstance()
{
    createFileUtils();

    createDirector();

    // set some defaults
    setIsHUDDisplayed(false);

    createTouchDispatcher();

    createAudioEngine(); // created and preloads music and sound effects.

    createOpeningScene();
}
added 626 characters in body
Source Link
Jasmine
  • 188
  • 6

in Cocos2D, doesn't the music continue to play until you pause or stop it?

If I want to change music between CCScene I usually do something like:

_dir->Instance()->getAudioEngine()->stopBackgroundMusic();
_dir->Instance()->getAudioEngine()->stopAllEffects();

// click!
_dir->Instance()->getAudioEngine()->playEffect("click.mp3", false);

...do whatever

Edit:

I dont use the shared director. I created my own director object with everything I need as member variables.

I load my music like this:

void AppDirector::createAudioEngine()
{
    CocosDenshion::SimpleAudioEngine* ae = new CocosDenshion::SimpleAudioEngine();

    ae->preloadBackgroundMusic("Tallahassee.mp3");
    ae->preloadBackgroundMusic("bigcountry.mp3");

    ae->preloadEffect("click.mp3");
    ae->preloadEffect("tap.mp3");

    ae->setBackgroundMusicVolume(0.5f);
    ae->setEffectsVolume(0.3f);

    setAudioEngine(ae);
}

in Cocos2D, doesn't the music continue to play until you pause or stop it?

If I want to change music between CCScene I usually do something like:

_dir->Instance()->getAudioEngine()->stopBackgroundMusic();
_dir->Instance()->getAudioEngine()->stopAllEffects();

// click!
_dir->Instance()->getAudioEngine()->playEffect("click.mp3", false);

...do whatever

in Cocos2D, doesn't the music continue to play until you pause or stop it?

If I want to change music between CCScene I usually do something like:

_dir->Instance()->getAudioEngine()->stopBackgroundMusic();
_dir->Instance()->getAudioEngine()->stopAllEffects();

// click!
_dir->Instance()->getAudioEngine()->playEffect("click.mp3", false);

...do whatever

Edit:

I dont use the shared director. I created my own director object with everything I need as member variables.

I load my music like this:

void AppDirector::createAudioEngine()
{
    CocosDenshion::SimpleAudioEngine* ae = new CocosDenshion::SimpleAudioEngine();

    ae->preloadBackgroundMusic("Tallahassee.mp3");
    ae->preloadBackgroundMusic("bigcountry.mp3");

    ae->preloadEffect("click.mp3");
    ae->preloadEffect("tap.mp3");

    ae->setBackgroundMusicVolume(0.5f);
    ae->setEffectsVolume(0.3f);

    setAudioEngine(ae);
}
Source Link
Jasmine
  • 188
  • 6

in Cocos2D, doesn't the music continue to play until you pause or stop it?

If I want to change music between CCScene I usually do something like:

_dir->Instance()->getAudioEngine()->stopBackgroundMusic();
_dir->Instance()->getAudioEngine()->stopAllEffects();

// click!
_dir->Instance()->getAudioEngine()->playEffect("click.mp3", false);

...do whatever