コード例 #1
0
 public void playMusic() {
   music.setVolume(1);
   music.setLooping(true);
   if (music != null && !music.isPlaying()) {
     music.play();
   }
 }
コード例 #2
0
  public GameScreen(final Drop gam) {
    this.game = gam;

    // load the images for the droplet and the bucket, 64x64 pixels each
    dropImage = new Texture(Gdx.files.internal("droplet.png"));
    bucketImage = new Texture(Gdx.files.internal("bucket.png"));

    // load the drop sound effect and the rain background "music"
    dropSound = Gdx.audio.newSound(Gdx.files.internal("drop.wav"));
    rainMusic = Gdx.audio.newMusic(Gdx.files.internal("rain.mp3"));
    rainMusic.setLooping(true);

    // create the camera and the SpriteBatch
    camera = new OrthographicCamera();
    camera.setToOrtho(false, 800, 480);

    // create a Rectangle to logically represent the bucket
    bucket = new Rectangle();
    bucket.x = 800 / 2 - 64 / 2; // center the bucket horizontally
    bucket.y = 20; // bottom left corner of the bucket is 20 pixels above
    // the bottom screen edge
    bucket.width = 64;
    bucket.height = 64;

    // create the raindrops array and spawn the first raindrop
    raindrops = new Array<Rectangle>();
    spawnRaindrop();
  }
コード例 #3
0
ファイル: Drop.java プロジェクト: hecao/testgithub
  @Override
  public void create() {
    // load the images for the droplet and the bucket, 48x48 pixels each
    dropImage = new Texture(Gdx.files.internal("data/droplet.png"));
    bucketImage = new Texture(Gdx.files.internal("data/bucket.png"));

    // load the drop sound effect and the rain background "music"
    dropSound = Gdx.audio.newSound(Gdx.files.internal("data/drop.wav"));
    rainMusic = Gdx.audio.newMusic(Gdx.files.internal("data/rain.mp3"));

    // start the playback of the background music immediately
    rainMusic.setLooping(true);
    rainMusic.play();

    // create the camera and the SpriteBatch
    camera = new OrthographicCamera();
    camera.setToOrtho(false, 800, 480);
    batch = new SpriteBatch();

    // create a Rectangle to logically represent the bucket
    bucket = new Rectangle();
    bucket.x = 800 / 2 - 48 / 2; // center the bucket horizontally
    bucket.y = 20; // bottom left corner of the bucket is 20 pixels above the bottom screen edge
    bucket.width = 48;
    bucket.height = 48;

    // create the raindrops array and spawn the first raindrop
    raindrops = new Array<Rectangle>();
    spawnRaindrop();
  }
コード例 #4
0
  @Override
  public void create() {
    music = Gdx.audio.newMusic(Gdx.files.internal("res/racerx.mp3"));
    music.setLooping(true);
    music.play();

    splashScreen = new SplashScreen(this);
    setScreen(splashScreen);
  }
コード例 #5
0
ファイル: MusicManager.java プロジェクト: Khopa/LD27
 public static void play(String newKey) {
   if (!enabled) return;
   if (music != null) {
     music.stop();
   }
   key = newKey;
   music = musics.get(key);
   music.setLooping(true);
   music.play();
 }
コード例 #6
0
ファイル: GameWorld.java プロジェクト: Arturinsh/Game_Client
  private void initMusic() {
    music = AssetsLoader.getMusic();

    boolean musicOn = preferences.getBoolean("musicOn", true);
    float musicVolume = preferences.getFloat("musicVolume", 1);
    music.setLooping(true);
    if (musicOn) {
      music.play();
    }
    music.setVolume(musicVolume);
  }
コード例 #7
0
 public static void reloadMusic() {
   if (MiningAdventure.PREF_AUDIO) {
     aud.stop();
     aud.dispose();
     aud = null;
     if (!MiningAdventure.sanic) {
       aud = Gdx.audio.newMusic(Gdx.files.internal("music/Game.mp3"));
     } else {
       aud = Gdx.audio.newMusic(Gdx.files.internal("music/SANIC.mp3"));
     }
     aud.play();
     aud.setLooping(true);
   }
 }
コード例 #8
0
ファイル: SFX.java プロジェクト: andreyas/BoxBob
  public static void build(final AssetManager manager) {

    hit = manager.get(PATH[0], Sound.class);
    doorClose = manager.get(PATH[1], Sound.class);
    doorOpen = manager.get(PATH[2], Sound.class);
    finish = manager.get(PATH[3], Sound.class);
    jump[0] = manager.get(PATH[4], Sound.class);
    jump[1] = manager.get(PATH[5], Sound.class);
    jump[2] = manager.get(PATH[6], Sound.class);
    jump[3] = manager.get(PATH[7], Sound.class);
    jump[4] = manager.get(PATH[8], Sound.class);
    playerDestroy = manager.get(PATH[9], Sound.class);
    noLives = manager.get(PATH[10], Sound.class);
    key = manager.get(PATH[11], Sound.class);
    bob = manager.get(PATH[12], Sound.class);
    dialog = manager.get(PATH[13], Sound.class);
    creditsShow = manager.get(PATH[14], Sound.class);
    creditsHide = manager.get(PATH[15], Sound.class);
    music1 = manager.get("Inktober-10.mp3", Music.class);
    music1.setLooping(true);
    music2 = manager.get("Guffawed-In-Joy.mp3", Music.class);
    music2.setLooping(true);
  }
コード例 #9
0
ファイル: MusicManager.java プロジェクト: stoeffel/SEPS-GRP1
  /**
   * Plays the given music (starts the streaming).
   *
   * <p>If there is already a music being played it is stopped automatically.
   */
  public void play(Music music) {
    // check if the music is enabled
    if (!enabled) return;

    // stop any music being played

    //        stop(); // removing this solves the restart problem (if menu-music is added, maybe
    // it's needed again)

    // start streaming the new music
    musicBeingPlayed = music;
    musicBeingPlayed.setVolume(volume);
    musicBeingPlayed.setLooping(true);
    musicBeingPlayed.play();
  }
コード例 #10
0
  @Override
  public void create() {
    shapeRenderer = new ShapeRenderer();
    batch = new SpriteBatch();
    camera = new OrthographicCamera();
    camera.setToOrtho(false, 800, 480);
    uiCamera = new OrthographicCamera();
    uiCamera.setToOrtho(false, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    uiCamera.update();

    font = new BitmapFont(Gdx.files.internal("arial.fnt"));

    background = new Texture("background.png");
    ground = new TextureRegion(new Texture("ground.png"));
    ceiling = new TextureRegion(ground);
    ceiling.flip(true, true);

    rock = new TextureRegion(new Texture("rock.png"));
    rockDown = new TextureRegion(rock);
    rockDown.flip(false, true);

    Texture frame1 = new Texture("plane1.png");
    frame1.setFilter(TextureFilter.Linear, TextureFilter.Linear);
    Texture frame2 = new Texture("plane2.png");
    Texture frame3 = new Texture("plane3.png");

    ready = new TextureRegion(new Texture("ready.png"));
    gameOver = new TextureRegion(new Texture("gameover.png"));

    plane =
        new Animation(
            0.05f,
            new TextureRegion(frame1),
            new TextureRegion(frame2),
            new TextureRegion(frame3),
            new TextureRegion(frame2));
    plane.setPlayMode(PlayMode.LOOP);

    music = Gdx.audio.newMusic(Gdx.files.internal("music.mp3"));
    music.setLooping(true);
    music.play();

    explode = Gdx.audio.newSound(Gdx.files.internal("explode.wav"));

    resetWorld();
  }
コード例 #11
0
ファイル: Drop.java プロジェクト: ryanmaund-dev/Libgdx-Drop
  /*
   *  The create() method initializes our all of our resources and loads them into memory before the rest of the game is run
   *  This method is the first called after the entry point(based on platform) and is only called once.
   *  This is also a convenient place to put boiler plate code for the rest of the game that we only want ran once on startup.
   *
   *  NOTE: Gdx.files.internal() defaults to the assets put into the Android project folder and takes String "filename.filetype" as a parameter.
   */
  @Override
  public void create() {
    dropImage = new Texture(Gdx.files.internal("droplet.png"));
    bucketImage = new Texture(Gdx.files.internal("bucket.png"));

    dropSound = Gdx.audio.newSound(Gdx.files.internal("droplet.mp3"));
    rainMusic = Gdx.audio.newMusic(Gdx.files.internal("rain.mp3"));

    rainMusic.setLooping(true); // set rainMusic (rain.mp3) to play over and over again
    rainMusic.play(); // starts the rainMusic audio

    camera = new OrthographicCamera(); // initialize camera, part of opengl/opengl-es.

    /*
     * sets the camera to 2 dimensional plane. Seems redundant since we are using OrthographicCamera() object.
     * Note: investigate camera settings
     */
    camera.setToOrtho(false, 800, 400);

    batch = new SpriteBatch(); // new sprite batch used in render() ie.Draws images.

    /*
     * set bucket properties. Use Rectangle object to represent bucket, track position and set size
     * used for collision detection with raindrop objects
     *
     */
    bucket = new Rectangle();
    bucket.x = 800 / 2 - 64 / 2;
    bucket.y = 20;
    bucket.width = 64;
    bucket.height = 64;

    /*
     * initializes Libgdx Array.
     * Note: Investigate how  Libgdx Array is different than regular Java Array.
     */
    raindrops = new Array<Rectangle>();

    /*
     * creates new raindrops to be drawn for our game. This method is called here to
     * start the first raindrop.
     */
    spawnRaindrop();
  }
コード例 #12
0
  public BaseLevel(GameScreen gameScreen) {
    m_GameScreen = gameScreen;
    m_Entities = new ArrayList<IEntity>();

    m_BackgroundMusic = Gdx.audio.newMusic(Gdx.files.internal("music/background.mp3"));
    m_BackgroundMusic.setVolume(gameScreen.m_Settings.m_BackgroundMusicVolume * 0.75f);
    m_BackgroundMusic.setLooping(true);
    m_BackgroundMusic.play();

    m_ClockTick = Gdx.audio.newSound(Gdx.files.internal("music/tick.mp3"));
    m_Powerup = Gdx.audio.newSound(Gdx.files.internal("music/powerup.wav"));
    m_Crash = Gdx.audio.newSound(Gdx.files.internal("music/crash.mp3"));
    m_Wind = Gdx.audio.newSound(Gdx.files.internal("music/wind.mp3"));

    // title
    m_BorderTexture = new Texture(Gdx.files.internal("map/border.png"));
    m_BorderTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
    TextureRegion borderRegion = new TextureRegion(m_BorderTexture, 0, 0, 800, 600);
    m_BorderSprite = new Sprite(borderRegion);
    m_BorderSprite.setColor(1, 1, 1, 0.5f);
  }
コード例 #13
0
  @Override
  public void show() {
    buttonRenderer = new SpriteBatch();

    if (aud != null && !MiningAdventure.PREF_AUDIO) {
      aud.stop();
      aud.dispose();
      aud = null;
    }

    if (aud == null && MiningAdventure.PREF_AUDIO) {
      if (!MiningAdventure.sanic) {
        aud = Gdx.audio.newMusic(Gdx.files.internal("music/Game.mp3"));
      } else {
        aud = Gdx.audio.newMusic(Gdx.files.internal("music/SANIC.mp3"));
      }
      aud.play();
      aud.setLooping(true);
    }

    Gdx.input.setInputProcessor(this);
  }
コード例 #14
0
ファイル: Drop.java プロジェクト: jmmrcp/Libgdx
  @Override
  public void create() {
    batch = new SpriteBatch();
    camera = new OrthographicCamera();
    camera.setToOrtho(false, 800, 480);
    // img = new Texture("badlogic.jpg");
    dropImage = new Texture(Gdx.files.internal("droplet.png"));
    bucketImage = new Texture(Gdx.files.internal("bucket.png"));

    bucket = new Rectangle();
    bucket.x = 800 / 2 - 64 / 2;
    bucket.y = 20;
    bucket.width = 64;
    bucket.width = 64;

    raindrops = new Array<Rectangle>();
    spawnRaindrop();

    dropSound = Gdx.audio.newSound(Gdx.files.internal("drop.wav"));
    rainMusic = Gdx.audio.newMusic(Gdx.files.internal("rain.mp3"));

    rainMusic.setLooping(true);
    rainMusic.play();
  }
コード例 #15
0
ファイル: Ringo.java プロジェクト: weimingtom/Java2hu
  public Ringo(float maxHealth, float x, float y) {
    super(maxHealth, x, y);

    int chunkHeight = 160;
    int chunkWidth = 128;

    Texture sprite = Loader.texture(FOLDER.child("anm.png"));
    sprite.setFilter(TextureFilter.MipMapLinearNearest, TextureFilter.Nearest);

    Sprite fbs = new Sprite(Loader.texture(FOLDER.child("fbs.png")));
    fbs.setScale(2F);

    TextureRegion nameTag = new TextureRegion(Loader.texture(FOLDER.child("nametag.png")));

    Animation idle =
        ImageSplitter.getAnimationFromSprite(sprite, chunkHeight, chunkWidth, 8F, 1, 2, 3, 4, 5);
    idle.setPlayMode(PlayMode.LOOP);

    Animation left =
        new MovementAnimation(
            ImageSplitter.getAnimationFromSprite(sprite, chunkHeight, chunkWidth, 8F, 11, 12),
            ImageSplitter.getAnimationFromSprite(sprite, chunkHeight, chunkWidth, 8F, 13, 14, 15),
            8f);
    Animation right =
        new MovementAnimation(
            ImageSplitter.getAnimationFromSprite(sprite, chunkHeight, chunkWidth, 8F, 6, 7),
            ImageSplitter.getAnimationFromSprite(sprite, chunkHeight, chunkWidth, 8F, 8, 9, 10),
            8f);

    Animation special =
        new StartupLoopAnimation(
            ImageSplitter.getAnimationFromSprite(sprite, chunkHeight, chunkWidth, 8F, 16, 17),
            ImageSplitter.getAnimationFromSprite(sprite, chunkHeight, chunkWidth, 8F, 18, 19, 20),
            8f);
    special.setPlayMode(PlayMode.NORMAL);

    Music bgm = new J2hMusic(Gdx.audio.newMusic(FOLDER.child("bgm.mp3")));
    bgm.setLooping(true);

    setAuraColor(AllStarUtil.from255RGB(104, 19, 52).mul(6f));
    setBgAuraColor(AllStarUtil.from255RGB(40, 40, 40));

    set(nameTag, bgm);
    set(fbs, idle, left, right, special);

    backgroundSpawner =
        new Setter<BackgroundBossAura>() {
          @Override
          public void set(final BackgroundBossAura t) {
            final Background bg =
                new Background(Loader.texture(FOLDER.child("bg.png"))) {
                  @Override
                  public void onDraw() {
                    setBlendFunc(GL20.GL_ONE_MINUS_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_COLOR);

                    super.onDraw();
                  };
                };

            bg.setFrameBuffer(t.getBackgroundBuffer());
            bg.setVelV(0.05d);
            bg.setVelU(-0.05d);
            bg.getSprite().setScale(0.75f);
            bg.getSprite().setAlpha(1f);
            bg.setZIndex(bg.getZIndex() - 20);

            game.spawn(bg);

            float speed = 10;

            // Layer 1
            final Background bge =
                new Background(Loader.texture(FOLDER.child("bge.png"))) {
                  @Override
                  public void onDraw() {
                    setBlendFunc(GL20.GL_DST_ALPHA, GL20.GL_ONE_MINUS_SRC_COLOR);

                    super.onDraw();
                  };
                };

            bge.setFrameBuffer(t.getBackgroundBuffer());
            bge.getSprite().setScale(1.5f);
            bge.setRotationDegs(speed);
            bge.getSprite().setAlpha(1f);
            bge.setZIndex(bg.getZIndex() - 2);

            game.spawn(bge);

            // Layer 2
            {
              Background bgeTwo =
                  new Background(Loader.texture(FOLDER.child("bge.png"))) {
                    @Override
                    public void onDraw() {
                      setBlendFunc(GL20.GL_SRC_COLOR, GL20.GL_ZERO);

                      super.onDraw();
                    };
                  };

              bgeTwo.getSprite().setScale(1.5f);
              bgeTwo.setFrameBuffer(t.getBackgroundBuffer());
              bgeTwo.setRotationDegs(-speed);
              bgeTwo.getSprite().setAlpha(1f);
              bgeTwo.setZIndex(bg.getZIndex() - 4);
              game.spawn(bgeTwo);
            }

            Game.getGame()
                .spawn(
                    new ClearBackground(bg.getZIndex() - 10) {
                      {
                        setFrameBuffer(t.getBackgroundBuffer());
                      }
                    });
          }
        };
  }
コード例 #16
0
ファイル: Assets.java プロジェクト: jcdoll/climber
 public static void startMusic(Music music) {
   music.play();
   music.setLooping(true);
 }
コード例 #17
0
 // Music
 public void loadMusic(String folder, String path, String key, boolean looping) {
   Music m = Gdx.audio.newMusic(Gdx.files.internal(folder + "/" + path));
   m.setLooping(looping);
   music.put(key, m);
 }
コード例 #18
0
  @Override
  public void show() {
    openingtheme.play();
    openingtheme.setLooping(true);
    // openingtheme.setVolume(game.state.volume);
    batch = new SpriteBatch();

    stage = new Stage();
    Gdx.input.setInputProcessor(stage);
    // Straight up stolen from https://www.pinterest.comore
    //        img = new Texture("menubackground1.png");
    img = new Texture("menu_background_fix.png");
    titleimg = new Texture("SlashHeroesTitle.png");
    img.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear);
    // change these numbers around so it looks good on the presentation phone
    TextureRegion region = new TextureRegion(img, 0, 0, 600, 400);
    sprite = new Sprite(region);
    sprite.setSize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    sprite.setOrigin(0, 0);

    skin = new Skin();
    // Generate a 1x1 white texture and store it in the skin named "white".
    Pixmap pixmap = new Pixmap(320, 75, Pixmap.Format.RGBA8888);
    pixmap.setColor(Color.GREEN);
    pixmap.fill();
    skin.add("white", new Texture(pixmap));

    // create the custom font
    FreeTypeFontGenerator generator =
        new FreeTypeFontGenerator(Gdx.files.internal("fonts/slkscre.ttf"));
    FreeTypeFontGenerator.FreeTypeFontParameter parameter =
        new FreeTypeFontGenerator.FreeTypeFontParameter();
    parameter.size = 80;
    BitmapFont OurFont = generator.generateFont(parameter);
    generator.dispose(); // don't forget to dispose to avoid memory leaks!

    // add ourfont to the skin for our buttons.
    skin.add("default", OurFont);

    // textbuttonstyle wont overwrite the font
    TextButtonStyle textButtonStyle = new TextButtonStyle();
    textButtonStyle.up = skin.newDrawable("white", Color.DARK_GRAY);
    textButtonStyle.down = skin.newDrawable("white", Color.DARK_GRAY);
    textButtonStyle.checked = skin.newDrawable("white", Color.BLUE);
    textButtonStyle.over = skin.newDrawable("white", Color.LIGHT_GRAY);
    textButtonStyle.font = skin.getFont("default");

    skin.add("default", textButtonStyle);

    // Create a button with the "default" TextButtonStyle.
    final TextButton PlayButton = new TextButton("PLAY", textButtonStyle);
    // final TextButton ContinueButton = new TextButton("Continue",textButtonStyle);
    final TextButton SettingsButton = new TextButton("Mute", textButtonStyle);
    final TextButton QuitButton = new TextButton("Quit", textButtonStyle);
    PlayButton.setPosition(Gdx.graphics.getWidth() / 2 - 160, Gdx.graphics.getHeight() / 2 - 150);
    // ContinueButton.setPosition(Gdx.graphics.getWidth()/2 - 160, Gdx.graphics.getHeight()/2 - 85);
    //        SettingsButton.setPosition(Gdx.graphics.getWidth()/2 - 160, Gdx.graphics.getHeight()/2
    // - 165);
    SettingsButton.setPosition(
        Gdx.graphics.getWidth() / 2 - 160, Gdx.graphics.getHeight() / 2 - 300);
    //        QuitButton.setPosition(Gdx.graphics.getWidth()/2 - 160, Gdx.graphics.getHeight()/2 -
    // 245);
    QuitButton.setPosition(Gdx.graphics.getWidth() / 2 - 160, Gdx.graphics.getHeight() / 2 - 450);
    stage.addActor(PlayButton);
    // stage.addActor(ContinueButton);
    stage.addActor(SettingsButton);
    stage.addActor(QuitButton);

    PlayButton.addListener(
        new ChangeListener() {
          public void changed(ChangeEvent event, Actor actor) {
            select.play();
            PlayButton.setText("Starting new game");
            openingtheme.stop();
            game.setScreen(game.introscreen);
          }
        });
    SettingsButton.addListener(
        new ChangeListener() {
          public void changed(ChangeEvent event, Actor actor) {
            // System.out.println("Clicked! Is checked: " + button.isChecked());
            select.play();
            if (game.state.volume == 0f) {
              game.state.volume = .7f;
              openingtheme.play();
              openingtheme.setVolume(game.state.volume);
              SettingsButton.setText("Mute");
            } else {
              game.state.volume = 0f;
              openingtheme.stop();
              SettingsButton.setText("Unmute");
            }

            // TODO make this mute and unmute the non existant sound
            // mute and unmute;
          }
        });
    QuitButton.addListener(
        new ChangeListener() {
          public void changed(ChangeEvent event, Actor actor) {
            select.play();
            openingtheme.stop();
            QuitButton.setText("Quitting");
            // TODO make this quit the correct way
            System.exit(0);
          }
        });
  }
コード例 #19
0
 public void playMusic() {
   if (music != null && !music.isPlaying()) {
     music.play();
     music.setLooping(loopMusic);
   }
 }