List of usage examples for com.badlogic.gdx Gdx audio
Audio audio
To view the source code for com.badlogic.gdx Gdx audio.
Click Source Link
From source file:actors.BasicSkel.java
public BasicSkel(float hlth, float dmg, float x, float y, int lvl, int pth, Stage stg, PlayScreen scrn) { this.setName("skeleton"); level = lvl;//from ww w. j av a 2s.com path = pth; stage = stg; screen = scrn; health = hlth; damage = dmg; slowTimer = -1; slowed = false; reset = false; poisoned = false; notmoving = false; if (damage < 220) texture = new Texture("skelsword1.png"); if (damage < 240 && damage >= 220) texture = new Texture("skelsword2.png"); if (damage >= 240) texture = new Texture("skelsword3.png"); sprite = new Sprite(texture); sprite.setScale(0.65f); setBounds(sprite.getX(), sprite.getY(), sprite.getWidth(), sprite.getHeight()); fireEffect = new ParticleEffect(); fireEffect.load(Gdx.files.internal("fire"), Gdx.files.internal("")); fireEffect.getEmitters().first().setPosition(getX(), getY()); fireballSound = Gdx.audio.newSound(Gdx.files.internal("fireball.wav")); iceEffect = new ParticleEffect(); iceEffect.load(Gdx.files.internal("ice"), Gdx.files.internal("")); iceEffect.getEmitters().first().setPosition(getX(), getY()); poisonEffect = new ParticleEffect(); poisonEffect.load(Gdx.files.internal("poison"), Gdx.files.internal("")); poisonEffect.getEmitters().first().setPosition(getX(), getY()); emptyHealthBar = new Sprite(new Texture("emptyBar.png")); fullHealthBar = new Sprite(new Texture("fullBar.png")); ColorAction red = new ColorAction(); red.setEndColor(Color.RED); red.setDuration(1f); MoveToAction moveOff = new MoveToAction(); moveOff.setPosition(-100, -100); kill = new SequenceAction(red, moveOff); this.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { if (health != 100000 && abs(screen.player.getX() - getX()) < screen.playerRange && abs(screen.player.getY() - getY()) < screen.playerRange) { if (screen.playerSpell == 1) { health -= screen.playerDamage; stage.addActor( new Fireball(screen.player.getX(), screen.player.getY(), getX() + 16, getY() + 16)); fireballSound.play(0.8f); fireEffect.start(); } if (screen.playerSpell == 2) { health -= screen.playerDamage * 0.75; stage.addActor( new IceBolt(screen.player.getX(), screen.player.getY(), getX() + 16, getY() + 16)); fireballSound.play(0.8f); iceEffect.start(); slowTimer = 3; if (health >= 0) slowed = true; } if (screen.playerSpell == 3) { poisoned = true; stage.addActor( new IceBolt(screen.player.getX(), screen.player.getY(), getX() + 16, getY() + 16)); fireballSound.play(0.8f); poisonEffect.start(); } } if (health <= 0) { poisoned = false; setName("dead"); health = 100000; clearActions(); addAction(kill); screen.skeletonDeath.play(1.0f); screen.addGold(5); } } }); velocity = 70; //Rectangle body = new Rectangle(getX(), getY(), getWidth(), getHeight()); //ScaleByAction sba = new ScaleByAction(); //sba.setAmount(0.25f); assignMovement(x, y); }
From source file:app.badlogicgames.superjumper.Assets.java
License:Apache License
public static void load() { background = loadTexture(prefix + "background.png"); backgroundRegion = new TextureRegion(background, 0, 0, 320, 480); items = loadTexture(prefix + "items.png"); multiplayer = loadTexture(prefix + "multiplayer.png"); // DATest//from w w w.j a va2 s. c o m // enemyBob = loadTexture(prefix + "monster2.png"); enemyBob1 = loadTexture(prefix + "monster2.png"); enemyBob2 = loadTexture(prefix + "monster3.png"); mainMenu = new TextureRegion(items, 0, 224, 300, 110); pauseMenu = new TextureRegion(items, 224, 128, 192, 96); ready = new TextureRegion(items, 320, 224, 192, 32); gameOver = new TextureRegion(items, 352, 256, 160, 96); highScoresRegion = new TextureRegion(Assets.items, 0, 257, 300, 110 / 3); logo = new TextureRegion(items, 0, 352, 274, 142); soundOff = new TextureRegion(items, 0, 0, 64, 64); soundOn = new TextureRegion(items, 64, 0, 64, 64); arrow = new TextureRegion(items, 0, 64, 64, 64); pause = new TextureRegion(items, 64, 64, 64, 64); spring = new TextureRegion(items, 128, 0, 32, 32); castle = new TextureRegion(items, 128, 64, 64, 64); coinAnim = new Animation(0.2f, new TextureRegion(items, 128, 32, 32, 32), new TextureRegion(items, 160, 32, 32, 32), new TextureRegion(items, 192, 32, 32, 32), new TextureRegion(items, 160, 32, 32, 32)); bobJump = new Animation(0.2f, new TextureRegion(items, 0, 128, 32, 32), new TextureRegion(items, 32, 128, 32, 32)); bobFall = new Animation(0.2f, new TextureRegion(items, 64, 128, 32, 32), new TextureRegion(items, 96, 128, 32, 32)); bobHit = new TextureRegion(items, 128, 128, 32, 32); squirrelFly = new Animation(0.2f, new TextureRegion(items, 0, 160, 32, 32), new TextureRegion(items, 32, 160, 32, 32)); platform = new TextureRegion(items, 64, 160, 64, 16); brakingPlatform = new Animation(0.2f, new TextureRegion(items, 64, 160, 64, 16), new TextureRegion(items, 64, 176, 64, 16), new TextureRegion(items, 64, 192, 64, 16), new TextureRegion(items, 64, 208, 64, 16)); font = new BitmapFont(Gdx.files.internal(prefix + "font.fnt"), Gdx.files.internal(prefix + "font.png"), false); music = Gdx.audio.newMusic(Gdx.files.internal(prefix + "music.mp3")); music.setLooping(true); music.setVolume(0.5f); if (Settings.soundEnabled) music.play(); jumpSound = Gdx.audio.newSound(Gdx.files.internal(prefix + "jump.wav")); highJumpSound = Gdx.audio.newSound(Gdx.files.internal(prefix + "highjump.wav")); hitSound = Gdx.audio.newSound(Gdx.files.internal(prefix + "hit.wav")); coinSound = Gdx.audio.newSound(Gdx.files.internal(prefix + "coin.wav")); clickSound = Gdx.audio.newSound(Gdx.files.internal(prefix + "click.wav")); FileHandle file = Gdx.files.internal(prefix + "platform.data"); platformDataString = file.readString(); }
From source file:at.juggle.games.memory.AssetManager.java
License:Apache License
public AssetManager(GameOptions options) { this.options = options; Preferences preferences = Gdx.app.getPreferences("memory_free_hd.prefs"); if (preferences.contains("soundOn")) { options.soundOn = preferences.getBoolean("soundOn"); }/*from w w w .j av a2s. c o m*/ font = new BitmapFont(getFileHandle("berlin_64.fnt"), false); smallFont = new BitmapFont(getFileHandle("berlin_42.fnt"), false); card = new Texture(getFileHandle("card-front.png")); cardBack = new Texture(getFileHandle("card-back.png")); cardBackMark = new Texture(getFileHandle("card-back-mark.png")); check = new Texture(getFileHandle("Check_32x32.png")); positive = new Texture(getFileHandle("Positive_256x256.png")); grey = new Texture(getFileHandle("grey.png")); background = new Texture(getFileHandle("background.jpg")); gradientTop = new Texture(getFileHandle("gradient_oben.png")); gradientBottom = new Texture(getFileHandle("gradient_unten.png")); if (GameOptions.isFreeVersion) { logo = new Texture(getFileHandle("Logo.png")); } else { logo = new Texture(getFileHandle("Logo_donated.png")); } cardBack.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear); cardBackMark.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear); logo.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear); Texture vehiclesTexture = new Texture(getFileHandle("vehicles.png")); vehiclesTexture.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear); TextureRegion[][] veh = TextureRegion.split(vehiclesTexture, 256, 256); icons = new TextureRegion[24]; icons[0] = new TextureRegion(loadTexture("animals/Butterfly_128x128.png")); icons[1] = new TextureRegion(loadTexture("animals/Dolphin_128x128.png")); icons[2] = new TextureRegion(loadTexture("animals/Elephant_128x128.png")); icons[3] = new TextureRegion(loadTexture("animals/Hippopotamus_128x128.png")); icons[4] = new TextureRegion(loadTexture("animals/Panda_128x128.png")); icons[5] = new TextureRegion(loadTexture("animals/Turtle_128x128.png")); icons[6] = new TextureRegion(loadTexture("vacation/surfboard_256x256.png")); icons[7] = new TextureRegion(loadTexture("vacation/umbrella_256x256.png")); int count = 0; for (int i = 0; i < veh.length; i++) { TextureRegion[] textureRegions = veh[i]; for (int j = 0; j < textureRegions.length; j++) { icons[8 + count] = textureRegions[j]; count++; } } // Particle effects fireworks = new ParticleEffect(); fireworks.load(getFileHandle("fireworks"), getFileHandle("")); // sounds sndFlipCard = Gdx.audio.newSound(getFileHandle("flipcard.ogg")); sndCheer = Gdx.audio.newSound(getFileHandle("drums.ogg")); sndDing = Gdx.audio.newSound(getFileHandle("ding.ogg")); }
From source file:awakening.view.menu.MainMenu.java
License:Apache License
/** * Constructor/*from ww w. j a va 2 s .c o m*/ * * @param game Tower Awakening's Game */ public MainMenu(TAGame game) { super(); this.game = game; this.music = Gdx.audio.newMusic(Gdx.files.internal("sound/menu/Dark Intro_0.ogg")); effect = Gdx.audio.newSound(Gdx.files.internal("sound/widget/Button Sound 53.wav")); stage = new Stage(); ///Language try { if (game.getLanguage().equals("ENGLISH")) { language = ResourceBundle.getBundle("awakening.view.menu.res_en_EN", locales[0]); } else if (game.getLanguage().equals("FRENCH")) { language = ResourceBundle.getBundle("awakening.view.menu.res_fr_FR", locales[1]); } else if (game.getLanguage().equals("ITALIAN")) { language = ResourceBundle.getBundle("awakening.view.menu.res_it_IT", locales[2]); } else { language = ResourceBundle.getBundle("awakening.view.menu.res", locales[0]); } } catch (java.util.MissingResourceException e) { System.out.println("yolo"); } ///Viewport camera = new OrthographicCamera(); view = new StretchViewport(Gdx.app.getGraphics().getWidth(), Gdx.app.getGraphics().getWidth(), camera); ///Background background = new Texture(Gdx.files.internal("img/menu/background-menu.png")); batch = new SpriteBatch(); ///Skin skin = new Skin(Gdx.files.internal("uiskin.json")); font = new BitmapFont(Gdx.files.internal("font/space.fnt")); style = new LabelStyle(font, Color.WHITE); ///Title title = new Label(language.getString("label_main_title"), skin); title.setStyle(style); ///Widgets Background widgetsBackground = new Image(new Texture(Gdx.files.internal("img/widget/bg widgets.png"))); ///Exit Button btnExit = new TextButton(language.getString("button_exit"), skin); ///Options Button btnOptions = new TextButton(language.getString("button_options"), skin); ///Multiplayer Button btnMultiplayer = new TextButton(language.getString("button_multiplayer"), skin); ///Solo Button btnSolo = new TextButton(language.getString("button_solo"), skin); }
From source file:be.ac.ucl.lfsab1509.bouboule.game.MyGame.java
License:Open Source License
@Override public void create() { // TODO Prod: LOG_ERROR Gdx.app.setLogLevel(Application.LOG_ERROR); Gdx.app.log("Matth", "Game: Create"); hitSounds = new Sound[5]; hitSounds[0] = Gdx.audio.newSound(Gdx.files.internal("music/sounds/hit1.mp3")); hitSounds[1] = Gdx.audio.newSound(Gdx.files.internal("music/sounds/hit2.mp3")); hitSounds[2] = Gdx.audio.newSound(Gdx.files.internal("music/sounds/hit3.mp3")); hitSounds[3] = Gdx.audio.newSound(Gdx.files.internal("music/sounds/hit4.mp3")); hitSounds[4] = Gdx.audio.newSound(Gdx.files.internal("music/sounds/hit5.mp3")); rand = new Random(); countdownSound = Gdx.audio.newSound(Gdx.files.internal("music/sounds/countdown.mp3")); if (GlobalSettings.GAME == null) // should not happen on Android!!! init(true);// w ww .ja va 2s . c om if (bNeedEndSounds) { winSound = Gdx.audio.newSound(Gdx.files.internal("music/sounds/win.mp3")); looseSound = Gdx.audio.newSound(Gdx.files.internal("music/sounds/loose.mp3")); } camera = CameraHelper.getCamera(GlobalSettings.APPWIDTH, GlobalSettings.APPHEIGHT); if (GlobalSettings.MENUS == null) { bGdxMenus = true; GlobalSettings.MENUS = new GdxMenus(); GlobalSettings.MENUS.launchInitMenu(); } else // e.g. Android => there is only one screen: Screen Game setScreenGame(); }
From source file:be.ac.ucl.lfsab1509.bouboule.game.MyGame.java
License:Open Source License
/** * @return the music for the menu (create a new one if it doesn't exist) *//* w ww. j a v a 2 s . c om*/ public Music getMenusMusic() { if (menusMusic == null) { menusMusic = Gdx.audio.newMusic(Gdx.files.internal("music/sounds/menu.mp3")); menusMusic.setLooping(true); } return menusMusic; }
From source file:be.ac.ucl.lfsab1509.bouboule.game.screen.ScreenGame.java
License:Open Source License
public ScreenGame() { loopMusicDefaultFile = loopMusicFile = Gdx.files.internal("music/levels/klez.mp3"); loopMusic = Gdx.audio.newMusic(loopMusicFile); loopMusic.setLooping(true);//from w ww . java 2s .c o m game = new GameLoop(GlobalSettings.GAME.getCamera(), true); if (Gdx.app.getType() == ApplicationType.iOS) // axes are inverted in iOS! AI.INIT_ORIENTATION = -1; }
From source file:be.ac.ucl.lfsab1509.bouboule.game.screen.ScreenGame.java
License:Open Source License
/** * @param cNewMusic should be a file that can be read by GDX */// w w w . j av a 2 s . co m public void setNewLoopMusic(final FileHandle pNewMusicFile) { if (pNewMusicFile.equals(loopMusicFile)) { return; } boolean bWasPlaying = loopMusic.isPlaying(); loopMusic.stop(); loopMusic.dispose(); loopMusicFile = pNewMusicFile; loopMusic = Gdx.audio.newMusic(pNewMusicFile); loopMusic.setLooping(true); if (bWasPlaying) { loopMusic.play(); } }
From source file:br.cefetmg.games.sounds.Sounds.java
public Sounds() { this.sucessSound = Gdx.audio.newSound(Gdx.files.internal("sounds/passouMinigame.mp3")); this.failSound = Gdx.audio.newSound(Gdx.files.internal("sounds/perdeuVida.mp3")); this.gameOverSound = Gdx.audio.newSound(Gdx.files.internal("sounds/gameover.mp3")); this.gameWinSound = Gdx.audio.newSound(Gdx.files.internal("sounds/fim_seq.mp3")); }
From source file:br.com.raphaelbruno.game.zombieinvaders.vr.GameBase.java
License:Apache License
@Override public void create() { modelBatch = new ModelBatch(); spriteBatch = new SpriteBatch(); soundBg = Gdx.audio.newMusic(Gdx.files.internal("sounds/bg.mp3")); playBg();/*from www. j a v a 2 s .c o m*/ setScreen(new SplashScreen(this)); }