當前位置: 首頁>>代碼示例>>Java>>正文


Java Sound類代碼示例

本文整理匯總了Java中com.badlogic.gdx.audio.Sound的典型用法代碼示例。如果您正苦於以下問題:Java Sound類的具體用法?Java Sound怎麽用?Java Sound使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Sound類屬於com.badlogic.gdx.audio包,在下文中一共展示了Sound類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: Basic

import com.badlogic.gdx.audio.Sound; //導入依賴的package包/類
public Basic(Matrix4 transform, double speeed, int hp, int health, int range, float coolDown, EnumSet<Types> types, EnumSet<Effects> effects, ModelInstance instance, btCollisionWorld world, IntMap<Entity> entities, List<Vector3> path, Map<String, Sound> sounds) {
    super(transform, speeed, hp, health, range, coolDown, types, effects, instance, new btCompoundShape(), world, entities, ATTACK_ANIMATION, ATTACK_OFFSET, path, sounds);
    ((btCompoundShape)shape).addChildShape(new Matrix4(new Vector3(0, 30, 0), new Quaternion().setEulerAngles(0, 0, 0), new Vector3(1, 1, 1)), new btBoxShape(new Vector3(75, 30, 90)));
    //System.out.println(getModelInstance().getAnimation("Spider_Armature|walk_ani_vor").id);
    listener = new AnimationController.AnimationListener() {
        @Override
        public void onEnd(AnimationController.AnimationDesc animationDesc) {

        }

        @Override
        public void onLoop(AnimationController.AnimationDesc animationDesc) {

        }
    };
    //animation.setAnimation("Spider_Armature|walk_ani_vor");
    //animation.animate("Spider_Armature|walk_ani_vor", -1);
    //animation.action("Spider_Armature|walk_ani_vor", 0, 1000, -1, 1, listener, 0);
    //animation.animate("Spider_Armature|Attack", 0, 1000, 1, 1, listener, 0);
    //animation.queue("Spider_Armature|walk_ani_vor", 0, 1000, -1, 1, listener, 0);
}
 
開發者ID:justinmarentette11,項目名稱:Tower-Defense-Galaxy,代碼行數:22,代碼來源:Basic.java

示例2: Ion

import com.badlogic.gdx.audio.Sound; //導入依賴的package包/類
public Ion(float posX, float posY, boolean flip)
{
    speed = 400;
    lifeTime = 180;
    flashLTime = 25;
    damage = 2;
    alive = true;

    this.posX = posX;
    this.posY = posY;
    bulletTexture = AssetLoader.assetManager.get("ion.png", Texture.class);
    bulletFlash = AssetLoader.assetManager.get("ionflash.png", Texture.class);
    bulletSound = AssetLoader.assetManager.get("ionsnd.wav", Sound.class);
    if(!flip)
        bulletSound.play();
    sprite = new Sprite(bulletTexture);
    sprite.setOriginCenter();
    sprite.setPosition(this.posX,this.posY);

    this.flip = flip;

    if(flip)
        sprite.setRotation(180);
}
 
開發者ID:UdealInferno,項目名稱:Parasites-of-HellSpace,代碼行數:25,代碼來源:Ion.java

示例3: Rocket

import com.badlogic.gdx.audio.Sound; //導入依賴的package包/類
public Rocket(float posX, float posY, boolean flip)
{
    speed = 300;
    lifeTime = 180;
    flashLTime = 25;
    damage = 3;
    alive = true;

    this.posX = posX;
    this.posY = posY;
    bulletTexture = AssetLoader.assetManager.get("bullet.png", Texture.class);
    bulletFlash = AssetLoader.assetManager.get("bulletflash.png", Texture.class);
    bulletSound = AssetLoader.assetManager.get("bulletsnd.wav", Sound.class);
    if(!flip)
        bulletSound.play(0.5f);
    sprite = new Sprite(bulletTexture);
    sprite.setOriginCenter();

    this.flip = flip;

    if(flip)
        sprite.setRotation(180);
}
 
開發者ID:UdealInferno,項目名稱:Parasites-of-HellSpace,代碼行數:24,代碼來源:Rocket.java

示例4: Player

import com.badlogic.gdx.audio.Sound; //導入依賴的package包/類
public Player() {
    super(0, 0);
    this.x = (float) (GameScreen.earth.getXCenter() + radius * Math.sin(angle));
    this.y = (float) (GameScreen.earth.getYCenter() + radius * Math.cos(angle));
    img = new Sprite(new Texture(Gdx.files.internal("player.png")));
    shoot = new Sound[4];
    for (int i = 1; i <= shoot.length; i++) {
        shoot[i - 1] = Gdx.audio.newSound(Gdx.files.internal("sound/shoot" + i + ".wav"));
    }
}
 
開發者ID:MrGussio,項目名稱:EarthInvadersGDX,代碼行數:11,代碼來源:Player.java

示例5: loadAssets

import com.badlogic.gdx.audio.Sound; //導入依賴的package包/類
private void loadAssets() {
    InternalFileHandleResolver fileHandler = new InternalFileHandleResolver();
    assetManager = new AssetManager(fileHandler);
    assetManager.setLoader(FreeTypeFontGenerator.class, new FreeTypeFontGeneratorLoader(fileHandler));

    assetManager.load(SKIN_PATH, Skin.class);
    assetManager.load(MASTER_PATH, TextureAtlas.class);
    assetManager.load(FONT_NORMAL_PATH, FreeTypeFontGenerator.class);
    assetManager.load(FONT_BOLD_PATH, FreeTypeFontGenerator.class);
    assetManager.load(MUSIC_PATH, Music.class);
    assetManager.load(MAIN_MENU_MUSIC_PATH, Music.class);
    assetManager.load(GOOD_PATH, Sound.class);
    assetManager.load(HALF_PATH, Sound.class);
    assetManager.load(BAD_PATH, Sound.class);
    assetManager.finishLoading();
}
 
開發者ID:DurianHLN,項目名稱:Polymorph,代碼行數:17,代碼來源:Polymorph.java

示例6: loadAssets

import com.badlogic.gdx.audio.Sound; //導入依賴的package包/類
public void loadAssets() {
    assetManager.clear();
    
    assetManager.load(DATA_PATH + "/skin/skin.json", Skin.class);
    
    for (String directory : imagePacks.keys()) {
        FileHandle folder = Gdx.files.local(directory);
        for (FileHandle file : folder.list()) {
            assetManager.load(file.path(), Pixmap.class);
            imagePacks.get(directory).add(file.nameWithoutExtension());
        }
    }
    
    assetManager.load(DATA_PATH + "/gfx/white.png", Pixmap.class);
    
    assetManager.load(DATA_PATH + "/sfx/coin.wav", Sound.class);
    assetManager.load(DATA_PATH + "/sfx/hit.wav", Sound.class);
    assetManager.load(DATA_PATH + "/sfx/jump.wav", Sound.class);
}
 
開發者ID:raeleus,項目名稱:bobbybird,代碼行數:20,代碼來源:Core.java

示例7: createSound

import com.badlogic.gdx.audio.Sound; //導入依賴的package包/類
/**
 * Erstellt einen Sound in der Sound-Datenbank und lädt ihn.
 *
 * @see AudioManager#createSound(String, String)
 * @see AudioManager#unloadSound(SoundKey)
 * @see AudioManager#playSound(SoundKey)
 * @see AudioManager#playSound(SoundKey, float)
 *
 * @param group zu welcher Gruppe gehört der Sound?
 * @param name der Name der Sounddatei mit Endung
 * @param autoUnload true damit der Sound beim Beenden ohne Warnung entladen wird. Sparsam benutzen.
 * @return ein Verweis auf den Sound der zum Abspielen benutzt werden kann
 */
public SoundKey createSound(String group, String name, boolean autoUnload)
{
    String soundId = group + "/" +name;

    if (soundMap.containsKey(soundId))
        return new SoundKey(soundId);

    Sound sound = Gdx.audio.newSound(Gdx.files.internal("data/sound/" + soundId));
    soundMap.put(soundId, sound);

    SoundKey soundKey = new SoundKey(soundId);

    if (autoUnload)
        autoUnloadSounds.add(soundKey);

    return soundKey;
}
 
開發者ID:Entwicklerpages,項目名稱:school-game,代碼行數:31,代碼來源:AudioManager.java

示例8: dispose

import com.badlogic.gdx.audio.Sound; //導入依賴的package包/類
/**
 * Wird aufgerufen, wenn der AudioManager nicht mehr benötigt wird.
 * Sollten noch Musik oder Sounds geladen sein, werden sie gestoppt und entladen.
 */
public void dispose()
{
    stopMusic();

    for (SoundKey soundKey : autoUnloadSounds)
    {
        unloadSound(soundKey);
    }

    if (!soundMap.isEmpty())
    {
        Gdx.app.log("DEBUG", "Some sounds (" + soundMap.size() + ") weren't unloaded by their creators!");

        for (Map.Entry<String, Sound> sound : soundMap.entrySet())
        {
            Gdx.app.log("DEBUG", "Auto unloading: " + sound.getKey());
            sound.getValue().stop();
            sound.getValue().dispose();
        }
    }
}
 
開發者ID:Entwicklerpages,項目名稱:school-game,代碼行數:26,代碼來源:AudioManager.java

示例9: CutsceneStoneAge

import com.badlogic.gdx.audio.Sound; //導入依賴的package包/類
public CutsceneStoneAge(MyGdxGame myGdxGame) {
	this.myGdxGame = myGdxGame;
	batch = myGdxGame.batch;
	sr = myGdxGame.sr;
	viewport = myGdxGame.viewport;
	camera = myGdxGame.camera;
	font = myGdxGame.font;

	particles = new Particles();

	bg = new Sprite(new Texture("sprites/orange.png"));
	girl = new Sprite(new Texture("sprites/girl.png"));
	stone = new Sprite(new Texture("sprites/stein_angemalt.png"));
	hominideSitzend = new Sprite(new Texture("sprites/hominide_sitzend.png"));
	hominideDuckend = new Sprite(new Texture("sprites/hominide_duckend.png"));
	hominideStehend = new Sprite(new Texture("sprites/hominide_stehend.png"));

	assetManager = new AssetManager();
	assetManager.load("music/tusch.mp3", Sound.class);
	assetManager.load("music/5_steinzeit.mp3", Music.class);

	assetManager.finishLoading();

	tusch = assetManager.get("music/tusch.mp3", Sound.class);
	musicStoneAge = assetManager.get("music/5_steinzeit.mp3", Music.class);
}
 
開發者ID:cdetamble,項目名稱:nomoore,代碼行數:27,代碼來源:CutsceneStoneAge.java

示例10: loadSfx

import com.badlogic.gdx.audio.Sound; //導入依賴的package包/類
/**
 * Loads a sound effect and associates it with its path.
 * @param fileName
 */
private void loadSfx(final String fileName) {
    if (!sfx.containsKey(fileName)) {
        Sound soundeffect = Gdx.audio.newSound(Gdx.files.internal(fileName));
        sfx.put(fileName, soundeffect);
    }
}
 
開發者ID:gradualgames,項目名稱:ggvm,代碼行數:11,代碼來源:SoundtrackManager.java

示例11: loadSounds

import com.badlogic.gdx.audio.Sound; //導入依賴的package包/類
/**
 * Load the sounds and musics used in the game.
 */
private void loadSounds() {
    assetManager.load("music/Artofescapism_-_Three_Star_Sky.mp3", Music.class);
    assetManager.load("music/item.mp3", Sound.class);
    assetManager.load("music/jump.wav", Sound.class);
    assetManager.load("music/lost.wav", Sound.class);
    assetManager.load("music/won.wav", Sound.class);
    assetManager.load("music/water.wav", Sound.class);
}
 
開發者ID:AndreFCruz,項目名稱:feup-lpoo-armadillo,代碼行數:12,代碼來源:Sounds.java

示例12: init

import com.badlogic.gdx.audio.Sound; //導入依賴的package包/類
public void init(AssetManager assetManager) {
    this.assetManager = assetManager;
    assetManager.setErrorListener(this);
    assetManager.load(TEXTURE_ATLAS_OBJECTS, TextureAtlas.class);
    // load sounds
    assetManager.load("sounds/jump.wav", Sound.class);
    assetManager.load("sounds/jump_with_feather.wav", Sound.class);
    assetManager.load("sounds/pickup_coin.wav", Sound.class);
    assetManager.load("sounds/pickup_feather.wav", Sound.class);
    assetManager.load("sounds/live_lost.wav", Sound.class);
    // load music
    assetManager.load("music/hair.ogg", Music.class);
    assetManager.finishLoading();

    Gdx.app.debug(TAG, "# of assets loaded: " + assetManager.getAssetNames().size);
    for (String a : assetManager.getAssetNames()) {
        Gdx.app.debug(TAG, "asset: " + a);
    }

    TextureAtlas atlas = assetManager.get(TEXTURE_ATLAS_OBJECTS);

    //激活平滑文理過度
    for (Texture t : atlas.getTextures()) {
        t.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear);
    }

    //創建遊戲資源對象
    bunny = new AssetBunny(atlas);
    rock = new AssetRock(atlas);
    goldCoin = new AssetGoldCoin(atlas);
    feather = new AssetFeather(atlas);
    levelDecoration = new AssetLevelDecoration(atlas);
    sounds = new AssetSounds(assetManager);
    music = new AssetMusic(assetManager);

    fonts = new AssetFonts();
}
 
開發者ID:davyjoneswang,項目名稱:libgdx-learnlib,代碼行數:38,代碼來源:Assets.java

示例13: AssetSounds

import com.badlogic.gdx.audio.Sound; //導入依賴的package包/類
public AssetSounds(AssetManager am) {
    jump = am.get("sounds/jump.wav", Sound.class);
    jumpWithFeather = am.get("sounds/jump_with_feather.wav", Sound.class);
    pickupCoin = am.get("sounds/pickup_coin.wav", Sound.class);
    pickupFeather = am.get("sounds/pickup_feather.wav", Sound.class);
    liveLost = am.get("sounds/live_lost.wav", Sound.class);
}
 
開發者ID:davyjoneswang,項目名稱:libgdx-learnlib,代碼行數:8,代碼來源:Assets.java

示例14: loadAudio

import com.badlogic.gdx.audio.Sound; //導入依賴的package包/類
public void loadAudio() {
    assetManager.load(MusicAsset.SOUND_MUSIC_MP3, Music.class);
    assetManager.load(SoundAsset.SOUND_EXPLOSION_WAV, Sound.class);
    assetManager.load(SoundAsset.SOUND_SHOOT_WAV, Sound.class);
    assetManager.load(SoundAsset.SOUND_POWERUP_WAV, Sound.class);
    assetManager.load(SoundAsset.BOMB_DROP, Sound.class);
    assetManager.load(SoundAsset.FIRE_MISSILE, Sound.class);
    assetManager.update();
}
 
開發者ID:ezet,項目名稱:penguins-in-space,代碼行數:10,代碼來源:AssetService.java

示例15: HealthPack

import com.badlogic.gdx.audio.Sound; //導入依賴的package包/類
public HealthPack() 
{
	posX = MathUtils.random(350)+ 50;
	posY = Gdx.graphics.getHeight();
	speed = 150f;
	texture = AssetLoader.assetManager.get("medkit.png", Texture.class);
	powerUpSound = AssetLoader.assetManager.get("powerupsnd.wav", Sound.class);
	sprite = new Sprite(texture);
	sprite.setOriginCenter();
	sprite.setScale(0.7f);
	sprite.setPosition(posX, posY);
}
 
開發者ID:UdealInferno,項目名稱:Parasites-of-HellSpace,代碼行數:13,代碼來源:HealthPack.java


注:本文中的com.badlogic.gdx.audio.Sound類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。