문제

bg music plays on splash,menu and gamescene when i had put the below code, but i want to make bg music to play only on my gamescene, can you please help me. Thank you.

public void onCreateResources(OnCreateResourcesCallback pOnCreateResourcesCallback) throws IOException
    {
        MusicFactory.setAssetBasePath("mfx/");

        try {
            music = MusicFactory.createMusicFromAsset(mEngine
                    .getMusicManager(), this, "abcd.wav");
            music.setLooping(true);
        } catch (IllegalStateException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } 
     ResourcesManager.prepareManager(mEngine, this, camera, getVertexBufferObjectManager());
        pOnCreateResourcesCallback.onCreateResourcesFinished();
  }

public void onCreateScene(OnCreateSceneCallback pOnCreateSceneCallback) throws IOException
    {
         music.play();
            SceneManager.getInstance().createSplashScene(pOnCreateSceneCallback);
     }
도움이 되었습니까?

해결책

I usually use music.pause() and music.resume() (because after stop the play does not work any more, I do not know why). When you leave a scene, you can call music.pause(). When you enter a scene, you can call music.resume();

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top