本文整理汇总了Java中com.badlogic.gdx.assets.loaders.TextureLoader类的典型用法代码示例。如果您正苦于以下问题:Java TextureLoader类的具体用法?Java TextureLoader怎么用?Java TextureLoader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TextureLoader类属于com.badlogic.gdx.assets.loaders包,在下文中一共展示了TextureLoader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Moon
import com.badlogic.gdx.assets.loaders.TextureLoader; //导入依赖的package包/类
public Moon(final AssetManager manager) {
manager.setLoader(Texture.class, new TextureLoader(new InternalFileHandleResolver()));
manager.setLoader(Sound.class, new SoundLoader(new InternalFileHandleResolver()));
manager.load(TEXTURE_FILENAME, Texture.class);
manager.load(SFX_MOON_CRASH_FILENAME, Sound.class);
manager.finishLoading();
texture = manager.get(TEXTURE_FILENAME);
crashSfx = manager.get(SFX_MOON_CRASH_FILENAME);
currentFrame = new TextureRegion(texture);
setWidth(currentFrame.getRegionWidth());
setHeight(currentFrame.getRegionHeight());
setOrigin(getWidth() / 2, getHeight() / 2);
reset();
}
示例2: Background
import com.badlogic.gdx.assets.loaders.TextureLoader; //导入依赖的package包/类
public Background(AssetManager manager) {
manager.setLoader(Texture.class, new TextureLoader(new InternalFileHandleResolver()));
manager.load(TEXTURE_FILENAME, Texture.class);
manager.finishLoading();
texture = manager.get(TEXTURE_FILENAME);
TextureRegion[] frames = TextureRegion.split(texture, FRAME_WIDTH, FRAME_HEIGHT)[0];
animation = new Animation(0.1f, frames[0], frames[1], frames[2]);
animation.setPlayMode(PlayMode.LOOP);
setWidth(FRAME_WIDTH);
setHeight(FRAME_HEIGHT);
background = new TiledDrawable(animation.getKeyFrame(0f));
}
示例3: MoonChain
import com.badlogic.gdx.assets.loaders.TextureLoader; //导入依赖的package包/类
public MoonChain(final AssetManager manager) {
manager.setLoader(Texture.class, new TextureLoader(new InternalFileHandleResolver()));
manager.setLoader(Sound.class, new SoundLoader(new InternalFileHandleResolver()));
manager.load(TEXTURE_FILENAME, Texture.class);
manager.load(SFX_CHAIN_PULL_FILENAME, Sound.class);
manager.finishLoading();
texture = manager.get(TEXTURE_FILENAME);
texture.setWrap(Texture.TextureWrap.ClampToEdge, Texture.TextureWrap.Repeat);
chainPullSfx = manager.get(SFX_CHAIN_PULL_FILENAME);
setWidth(texture.getWidth());
setHeight(texture.getHeight() * TILE_COUNT);
setOrigin(getWidth() / 2, 0);
// Note: scale is not used in draw for the chain, this is a hack to make easier to put the chain down
setScale(3f, 3f);
collisionArea = new Rectangle(getX(), getY(), getWidth(), getHeight());
position = new Vector2(getX(), getY());
}
示例4: Enemy
import com.badlogic.gdx.assets.loaders.TextureLoader; //导入依赖的package包/类
public Enemy(final AssetManager manager) {
manager.setLoader(Texture.class, new TextureLoader(new InternalFileHandleResolver()));
manager.setLoader(Sound.class, new SoundLoader(new InternalFileHandleResolver()));
manager.load(TEXTURE_FILENAME, Texture.class);
manager.load(SFX_HIT_FILENAME, Sound.class);
manager.finishLoading();
texture = manager.get(TEXTURE_FILENAME);
regions = TextureRegion.split(texture, FRAME_WIDTH, FRAME_HEIGHT)[0];
idle = new Animation(0.1f, regions[0], regions[1], regions[2]);
idle.setPlayMode(Animation.PlayMode.LOOP);
hitSfx = manager.get(SFX_HIT_FILENAME);
currentFrame = idle.getKeyFrame(0.0f);
setWidth(currentFrame.getRegionWidth());
setHeight(currentFrame.getRegionHeight());
setOrigin(getWidth() / 2, getHeight() / 2);
collisionArea = new Rectangle(50, 0, (int)getWidth() - 100, (int)getHeight());
health = 5;
}
示例5: AssetManager
import com.badlogic.gdx.assets.loaders.TextureLoader; //导入依赖的package包/类
/** Creates a new AssetManager with all default loaders. */
public AssetManager (FileHandleResolver resolver) {
setLoader(BitmapFont.class, new BitmapFontLoader(resolver));
setLoader(Music.class, new MusicLoader(resolver));
setLoader(Pixmap.class, new PixmapLoader(resolver));
setLoader(Sound.class, new SoundLoader(resolver));
setLoader(TextureAtlas.class, new TextureAtlasLoader(resolver));
setLoader(Texture.class, new TextureLoader(resolver));
setLoader(Skin.class, new SkinLoader(resolver));
setLoader(ParticleEffect.class, new ParticleEffectLoader(resolver));
setLoader(PolygonRegion.class, new PolygonRegionLoader(resolver));
setLoader(I18NBundle.class, new I18NBundleLoader(resolver));
setLoader(Model.class, ".g3dj", new G3dModelLoader(new JsonReader(), resolver));
setLoader(Model.class, ".g3db", new G3dModelLoader(new UBJsonReader(), resolver));
setLoader(Model.class, ".obj", new ObjLoader(resolver));
executor = new AsyncExecutor(1);
}
示例6: getDependencies
import com.badlogic.gdx.assets.loaders.TextureLoader; //导入依赖的package包/类
/** Retrieves TiledMap resource dependencies
*
* @param fileName
* @param parameter not used for now
* @return dependencies for the given .tmx file */
@Override
public Array<AssetDescriptor> getDependencies (String fileName, FileHandle tmxFile, Parameters parameter) {
Array<AssetDescriptor> dependencies = new Array<AssetDescriptor>();
try {
root = xml.parse(tmxFile);
boolean generateMipMaps = (parameter != null ? parameter.generateMipMaps : false);
TextureLoader.TextureParameter texParams = new TextureParameter();
texParams.genMipMaps = generateMipMaps;
if (parameter != null) {
texParams.minFilter = parameter.textureMinFilter;
texParams.magFilter = parameter.textureMagFilter;
}
for (FileHandle image : loadTilesets(root, tmxFile)) {
dependencies.add(new AssetDescriptor(image, Texture.class, texParams));
}
return dependencies;
} catch (IOException e) {
throw new GdxRuntimeException("Couldn't load tilemap '" + fileName + "'", e);
}
}
示例7: Assets
import com.badlogic.gdx.assets.loaders.TextureLoader; //导入依赖的package包/类
public Assets()
{
textureParameter = new TextureLoader.TextureParameter();
//textureParameter.genMipMaps = true;
textureParameter.magFilter = Texture.TextureFilter.Linear;
textureParameter.minFilter = Texture.TextureFilter.Linear;
resolver = new MaryoFileHandleResolver();
manager = new AssetManager(resolver);
particleEffectParameter = new ParticleEffectLoader.ParticleEffectParameter();
particleEffectParameter.imagesDir = resolver.resolve("data/animation/particles");
// set the loaders for the generator and the fonts themselves
manager.setLoader(FreeTypeFontGenerator.class, new FreeTypeFontGeneratorLoader(resolver));
manager.setLoader(BitmapFont.class, ".ttf", new FreetypeFontLoader(resolver));
manager.setLoader(ParticleEffect.class, ".p", new ParticleEffectLoader(resolver));
manager.setLoader(Sound.class, ".mp3", new SoundLoader(new InternalFileHandleResolver()));
manager.setLoader(Music.class, ".mp3", new MusicLoader(new InternalFileHandleResolver()));
}
示例8: getDependencies
import com.badlogic.gdx.assets.loaders.TextureLoader; //导入依赖的package包/类
@Override
public Array<AssetDescriptor> getDependencies(String fileName, FileHandle file, P parameters) {
final Array<AssetDescriptor> deps = new Array();
ModelData data = loadModelData(file, parameters);
if (data == null) return deps;
ObjectMap.Entry<String, ModelData> item = new ObjectMap.Entry<String, ModelData>();
item.key = fileName;
item.value = data;
synchronized (items) {
items.add(item);
}
TextureLoader.TextureParameter textureParameter = (parameters != null)
? parameters.textureParameter
: defaultParameters.textureParameter;
for (final ModelMaterial modelMaterial : data.materials) {
if (modelMaterial.textures != null) {
for (final ModelTexture modelTexture : modelMaterial.textures) {
String fName = modelTexture.fileName;
if (fName.contains("/")) {
fName = fName.substring(fName.lastIndexOf("/") + 1);
}
deps.add(new AssetDescriptor(currentAsset.dependenciesPath + fName, Texture.class, textureParameter));
}
}
}
return deps;
}
示例9: loadAsync
import com.badlogic.gdx.assets.loaders.TextureLoader; //导入依赖的package包/类
private void loadAsync() {
Thread th = new Thread(new Runnable() {
@Override
public void run() {
if (thumbnail)
createThumb();
final TextureLoader tl = new TextureLoader(new AbsoluteFileHandleResolver());
try {
tl.loadAsync(assetManager, ImgName, Gdx.files.absolute(mPath), null);
Gdx.app.postRunnable(new Runnable() {
@Override
public void run() {
// Log.info(log, "LoadSync " + mPath + ":" + ImgName);
mImageTex = tl.loadSync(assetManager, ImgName, Gdx.files.absolute(mPath), null);
Sprite sprite = new Sprite(mImageTex);
spriteWidth = sprite.getWidth();
spriteHeight = sprite.getHeight();
setSprite(sprite, reziseHeight);
// Log.info(log, "LoadSync " + mPath + ":" + ImgName + " ready");
}
});
} catch (Exception e) {
//e.printStackTrace();
}
}
});
th.start();
}
示例10: getDependencies
import com.badlogic.gdx.assets.loaders.TextureLoader; //导入依赖的package包/类
@Override
public Array<AssetDescriptor> getDependencies(String fileName, FileHandle file, TextureAtlasLoader.TextureAtlasParameter parameter) {
FileHandle imgDir = file.parent();
map = LyU.createDictionaryWithContentsOfFile(file);
ObjectMap<String, Object> metadata = (ObjectMap<String, Object>) map.get("metadata");
String dependFile = (String) metadata.get("textureFileName");
Array<AssetDescriptor> res = new Array<AssetDescriptor>();
TextureLoader.TextureParameter params = new TextureLoader.TextureParameter();
params.magFilter = Texture.TextureFilter.Linear;
params.minFilter = Texture.TextureFilter.Linear;
params.format = Pixmap.Format.RGBA8888;
texture = new Texture(imgDir.child(dependFile));
res.add(new AssetDescriptor(imgDir.child(dependFile), Texture.class, params));
return res;
}
示例11: Player
import com.badlogic.gdx.assets.loaders.TextureLoader; //导入依赖的package包/类
public Player(final AssetManager manager) {
manager.setLoader(Texture.class, new TextureLoader(new InternalFileHandleResolver()));
manager.setLoader(Sound.class, new SoundLoader(new InternalFileHandleResolver()));
manager.load(TEXTURE_FILENAME, Texture.class);
manager.load(SFX_HIT_FILENAME, Sound.class);
manager.load(SFX_DIE_FILENAME, Sound.class);
manager.finishLoading();
texture = manager.get(TEXTURE_FILENAME);
textureRegions = TextureRegion.split(texture, FRAME_WIDTH, FRAME_HEIGHT)[0];
idle = new Animation(0.1f, textureRegions[0], textureRegions[1], textureRegions[2]);
idle.setPlayMode(Animation.PlayMode.LOOP);
walk = new Animation(0.3f, textureRegions[3], textureRegions[4]);
walk.setPlayMode(Animation.PlayMode.LOOP);
attack = new Animation(0.3f, textureRegions[5], textureRegions[6], textureRegions[7]);
attack.setPlayMode(Animation.PlayMode.NORMAL);
hitSfx = manager.get(SFX_HIT_FILENAME);
dieSfx = manager.get(SFX_DIE_FILENAME);
setWidth(FRAME_WIDTH);
setHeight(FRAME_HEIGHT);
setOrigin(getWidth() / 2, getHeight() / 2);
state = State.IDLE;
currentFrame = idle.getKeyFrame(0.0f);
moveTarget = new Vector2(-1, -1);
position = new Vector2(getX(), getY());
velocity = new Vector2(0, 0);
collisionArea = new Rectangle(getX() + 50, getY(), (int)getWidth() - 100, (int)getHeight());
attackArea = new Rectangle(0, 0, 0, 0);
}
示例12: Boss
import com.badlogic.gdx.assets.loaders.TextureLoader; //导入依赖的package包/类
public Boss(final AssetManager manager) {
manager.setLoader(Texture.class, new TextureLoader(new InternalFileHandleResolver()));
manager.setLoader(Sound.class, new SoundLoader(new InternalFileHandleResolver()));
manager.load(TEXTURE_FILENAME, Texture.class);
manager.load(SFX_HIT_FILENAME, Sound.class);
manager.finishLoading();
texture = manager.get(TEXTURE_FILENAME);
regions = TextureRegion.split(texture, FRAME_WIDTH, FRAME_HEIGHT)[0];
idle = new Animation(0.1f, regions[0], regions[1], regions[2]);
idle.setPlayMode(Animation.PlayMode.LOOP);
hitSfx = manager.get(SFX_HIT_FILENAME);
currentFrame = idle.getKeyFrame(0.0f);
setWidth(currentFrame.getRegionWidth());
setHeight(currentFrame.getRegionHeight());
setOrigin(getWidth() / 2, getHeight() / 2);
collisionArea = new Rectangle(getX(), getY() + 80, (int) getWidth(), (int) getHeight() - 170);
health = 50;
raging = false;
color = Color.WHITE;
setColor(color);
flipX = false;
}
示例13: StageClearScreen
import com.badlogic.gdx.assets.loaders.TextureLoader; //导入依赖的package包/类
public StageClearScreen(final ThrowTheMoonGame game) {
this.manager = new AssetManager();
this.stage = new Stage(new StretchViewport(WIDTH, HEIGHT));
manager.setLoader(Texture.class, new TextureLoader(new InternalFileHandleResolver()));
manager.load(TEXTURE_FILENAME, Texture.class);
manager.load(MUSIC_FILENAME, Music.class);
manager.finishLoading();
background = manager.get(TEXTURE_FILENAME);
music = manager.get(MUSIC_FILENAME);
Image backgroundImg = new Image(background);
stage.addActor(backgroundImg);
Gdx.input.setInputProcessor(stage);
stage.addListener(new ActorGestureListener() {
@Override
public void tap(InputEvent event, float x, float y, int count, int button) {
music.stop();
game.setScreen(new GameScreen(game));
super.tap(event, x, y, count, button);
}
});
music.setLooping(true);
music.play();
}
示例14: GameScene
import com.badlogic.gdx.assets.loaders.TextureLoader; //导入依赖的package包/类
public GameScene(ModelLoader.ModelParameters modelParameters,
TextureLoader.TextureParameter textureParameter,
ParticleEffectLoader.ParticleEffectLoadParameter pfxParameter,
String pfxPath, String modelPath, String modelExt, ObjectMap<String, GameObjectBlueprint> sharedBlueprints) {
this.sharedBlueprints = sharedBlueprints;
this.assets = new BlenderAssetManager(modelParameters, textureParameter, pfxParameter,
pfxPath, modelPath, modelExt);
}
示例15: GameSceneManager
import com.badlogic.gdx.assets.loaders.TextureLoader; //导入依赖的package包/类
public GameSceneManager(ModelLoader.ModelParameters modelParameters,
TextureLoader.TextureParameter textureParameter,
ParticleEffectLoader.ParticleEffectLoadParameter pfxParameter,
String pfxPath, String modelPath, String modelExt) {
this.modelPath = modelPath;
this.modelExt = modelExt;
this.pfxPath = pfxPath;
this.modelParameters = modelParameters;
this.textureParameter = textureParameter;
this.pfxParameter = pfxParameter;
}