本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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"));
}
}
示例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();
}
示例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);
}
示例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;
}
示例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();
}
}
}
示例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);
}
示例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);
}
}
示例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);
}
示例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();
}
示例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);
}
示例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();
}
示例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);
}