public Sound loadSoundResourceFromSD(String nameResource) { if (BuildConfig.TEST_VERSION) { try { return SoundFactory.createSoundFromAsset( this.mEngine.getSoundManager(), getActivity(), nameResource); } catch (IOException e) { e.printStackTrace(); return null; } } else { String path = Environment.getExternalStorageDirectory() + "/Android/data/" + getActivity().getPackageName() + "/files/" + songName + "/mfx/" + nameResource + ".nomedia"; try { File tmp = new File(path); FileInputStream fis = new FileInputStream(tmp); byte[] decodeHeader = tmp.getName().replace(".nomedia", "").getBytes(); System.gc(); return SoundFactory.createSoundFromFileDescriptor( this.mEngine.getSoundManager(), fis.getFD(), decodeHeader.length, tmp.length() - decodeHeader.length); } catch (Exception e) { e.printStackTrace(); return null; } } }
private void loadSounds() { SoundFactory.setAssetBasePath("sfx/"); try { soundIntro = SoundFactory.createSoundFromAsset( this.engine.getSoundManager(), this.activity, "intro.ogg"); soundIntro.setLooping(false); } catch (IllegalStateException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
public void onCreateResources(OnCreateResourcesCallback pOnCreateResourcesCallback) throws IOException { ResourcesManager.prepareManager(mEngine, this, camera, getVertexBufferObjectManager()); MusicFactory.setAssetBasePath("sfx/"); SoundFactory.setAssetBasePath("sfx/"); try { myMusic = MusicFactory.createMusicFromAsset(mEngine.getMusicManager(), this, "group1-Menu.mp3"); } catch (IOException e) { e.printStackTrace(); } try { explosion1 = MusicFactory.createMusicFromAsset(mEngine.getMusicManager(), this, "explodingsample.mp3"); explosion2 = MusicFactory.createMusicFromAsset(mEngine.getMusicManager(), this, "explodingsample.mp3"); explosion3 = MusicFactory.createMusicFromAsset(mEngine.getMusicManager(), this, "explodingsample.mp3"); } catch (IOException e) { e.printStackTrace(); } pOnCreateResourcesCallback.onCreateResourcesFinished(); }
public void onCreateResources() { // nothing SoundFactory.setAssetBasePath(getBasePathFolder() + "/mfx/"); BitmapTextureAtlasTextureRegionFactory.setAssetBasePath(getBasePathFolder() + "/gfx/"); mTexturePackLoaderFromSource = new TexturePackLoaderFromSource(this.getTextureManager(), pAssetManager, "santa/gfx/"); }
@Override public void onCreateResources() { SoundFactory.setAssetBasePath("ohanashi/mfx/"); // Sound Resources MusicFactory.setAssetBasePath("ohanashi/mfx/"); BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("ohanashi/gfx/"); // Image mTexturePackLoaderFromSource = new TexturePackLoaderFromSource(getTextureManager(), pAssetManager, "ohanashi/gfx/"); super.onCreateResources(); }
public Sound createSound(String soundFileName) { Sound sound = null; try { sound = SoundFactory.createSoundFromAsset(engine.getSoundManager(), context, soundFileName); } catch (final IOException e) { Debug.e(e); } return sound; }
public SoundResource(GameActivity game) { _game = game; SoundFactory.setAssetBasePath("mfx/"); SoundManager sm = _game.getEngine().getSoundManager(); try { MOVE = SoundFactory.createSoundFromAsset(sm, _game, "click_move.ogg"); DROP = SoundFactory.createSoundFromAsset(sm, _game, "group.ogg"); DROP6 = SoundFactory.createSoundFromAsset(sm, _game, "group6.ogg"); TIME = SoundFactory.createSoundFromAsset(sm, _game, "time.ogg"); TACK = SoundFactory.createSoundFromAsset(sm, _game, "tack.ogg"); SLIDE = SoundFactory.createSoundFromAsset(sm, _game, "slide.ogg"); LOST = SoundFactory.createSoundFromAsset(sm, _game, "lost.ogg"); WOOSH = SoundFactory.createSoundFromAsset(sm, _game, "woosh.ogg"); } catch (final IOException e) { throw new RuntimeException(e); } }
private void loadGameMusic() { SoundFactory.setAssetBasePath("mfx/other/"); winSoundList = new ArrayList<Sound>(); loseSoundList = new ArrayList<Sound>(); halfWinSoundList = new ArrayList<Sound>(); try { winSoundList.add( SoundFactory.createSoundFromAsset(getEngine().getSoundManager(), activity, "win.ogg")); loseSoundList.add( SoundFactory.createSoundFromAsset(getEngine().getSoundManager(), activity, "lose.ogg")); loseSoundList.add( SoundFactory.createSoundFromAsset(getEngine().getSoundManager(), activity, "lose1.ogg")); halfWinSoundList.add( SoundFactory.createSoundFromAsset( getEngine().getSoundManager(), activity, "halfwin0.ogg")); halfWinSoundList.add( SoundFactory.createSoundFromAsset( getEngine().getSoundManager(), activity, "halfwin1.ogg")); halfWinSoundList.add( SoundFactory.createSoundFromAsset( getEngine().getSoundManager(), activity, "halfwin2.ogg")); startGameSound = SoundFactory.createSoundFromAsset(getEngine().getSoundManager(), activity, "go.ogg"); goodClickSound = SoundFactory.createSoundFromAsset( getEngine().getSoundManager(), activity, "goodClick.ogg"); wrongClickSound = SoundFactory.createSoundFromAsset( getEngine().getSoundManager(), activity, "wrongClick.ogg"); } catch (IOException e) { e.printStackTrace(); } }
public void loadGameResources() { BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/"); SoundFactory.setAssetBasePath("sfx/"); MusicFactory.setAssetBasePath("sfx/"); condomTextureAtlas = new BitmapTextureAtlas(activity.getTextureManager(), 64, 64); chickenTextureAtlas = new BitmapTextureAtlas(activity.getTextureManager(), 64, 64); tabletTextureAtlas = new BitmapTextureAtlas(activity.getTextureManager(), 64, 64); waterTextureAtlas = new BitmapTextureAtlas(activity.getTextureManager(), 64, 64); garlicTextureAtlas = new BitmapTextureAtlas(activity.getTextureManager(), 32, 32); pineappleTextureAtlas = new BitmapTextureAtlas(activity.getTextureManager(), 64, 64); alcoholTextureAtlas = new BitmapTextureAtlas(activity.getTextureManager(), 32, 64); blueTextureAtlas = new BitmapTextureAtlas(activity.getTextureManager(), 256, 256); redTextureAtlas = new BitmapTextureAtlas(activity.getTextureManager(), 256, 256); razorTextureAtlas = new BitmapTextureAtlas(activity.getTextureManager(), 256, 256); winTextureAtlas = new BitmapTextureAtlas(activity.getTextureManager(), 1024, 512); lossTextureAtlas = new BitmapTextureAtlas(activity.getTextureManager(), 1024, 512); pauseTextureAtlas = new BitmapTextureAtlas(activity.getTextureManager(), 64, 64); cigarreteTextureAtlas = new BitmapTextureAtlas(activity.getTextureManager(), 64, 64); soyaTextureAtlas = new BitmapTextureAtlas(activity.getTextureManager(), 32, 16); bonusTextureAtlas = new BitmapTextureAtlas(activity.getTextureManager(), 64, 64); // create the texture regions of the different Sprites condomTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset( condomTextureAtlas, activity, "condom2f.png", 0, 0); chickenTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset( chickenTextureAtlas, activity, "chichen_final.png", 0, 0); tabletTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset( tabletTextureAtlas, activity, "tab.png", 0, 0); garlicTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset( garlicTextureAtlas, activity, "garlicf.png", 0, 0); pineappleTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset( pineappleTextureAtlas, activity, "pinef.png", 0, 0); waterTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset( waterTextureAtlas, activity, "water.png", 0, 0); alcoholTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset( alcoholTextureAtlas, activity, "waragi.png", 0, 0); blueTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset( blueTextureAtlas, activity, "blue3.png", 0, 0); redTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset( redTextureAtlas, activity, "red2.png", 0, 0); razorTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset( razorTextureAtlas, activity, "razor.png", 0, 0); winTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset( winTextureAtlas, activity, "win.png", 0, 0); lossTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset( lossTextureAtlas, activity, "loss.png", 0, 0); cigarreteTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset( cigarreteTextureAtlas, activity, "cigaret5.png", 0, 0); soyaTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset( soyaTextureAtlas, activity, "sayaf.png", 0, 0); bonusTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset( bonusTextureAtlas, activity, "health.png", 0, 0); pauseTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset( pauseTextureAtlas, activity, "pause.png", 0, 0); mBackgroundTexture = new BitmapTextureAtlas( engine.getTextureManager(), (int) camera.getWidth(), (int) camera.getHeight(), TextureOptions.DEFAULT); mBgTexture = BitmapTextureAtlasTextureRegionFactory.createFromAsset( mBackgroundTexture, activity, "game_background.jpg", 0, 0); // scoreFontTexture = new BitmapTextureAtlas(engine.getTextureManager(), // 256, 256, TextureOptions.BILINEAR_PREMULTIPLYALPHA); // FontFactory.setAssetBasePath("font/"); // ResourceManager.mFont = FontFactory.createFromAsset(scoreFontTexture, // engine.getTextureManager(), // "Droid.ttf", FONT_SIZE, true, Color.BLACK); ResourceManager.mFont = FontFactory.create( engine.getFontManager(), engine.getTextureManager(), 256, 256, Typeface.create(Typeface.DEFAULT, Typeface.BOLD), FONT_SIZE); // Load our "sound.mp3" file into a Sound object try { mGameTapSound = SoundFactory.createSoundFromAsset(engine.getSoundManager(), activity, "tap.mp3"); badFoodSound = SoundFactory.createSoundFromAsset(engine.getSoundManager(), activity, "plast.mp3"); } catch (IOException e) { e.printStackTrace(); } // Load our "music.mp3" file into a music object try { gameMusic = MusicFactory.createMusicFromAsset(engine.getMusicManager(), activity, "welcome.mp3"); } catch (IOException e) { e.printStackTrace(); } ResourceManager.mFont.load(); ResourceManager.mBackgroundTexture.load(); condomTextureAtlas.load(); chickenTextureAtlas.load(); tabletTextureAtlas.load(); pineappleTextureAtlas.load(); waterTextureAtlas.load(); alcoholTextureAtlas.load(); garlicTextureAtlas.load(); blueTextureAtlas.load(); redTextureAtlas.load(); razorTextureAtlas.load(); winTextureAtlas.load(); lossTextureAtlas.load(); pauseTextureAtlas.load(); cigarreteTextureAtlas.load(); soyaTextureAtlas.load(); bonusTextureAtlas.load(); }