当前位置: 首页>>代码示例>>Java>>正文


Java TextureLoader类代码示例

本文整理汇总了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(); 
}
 
开发者ID:broken-shotgun,项目名称:throw-the-moon,代码行数:19,代码来源:Moon.java

示例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));
}
 
开发者ID:broken-shotgun,项目名称:throw-the-moon,代码行数:17,代码来源:Background.java

示例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());
}
 
开发者ID:broken-shotgun,项目名称:throw-the-moon,代码行数:23,代码来源:MoonChain.java

示例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;
}
 
开发者ID:broken-shotgun,项目名称:throw-the-moon,代码行数:25,代码来源:Enemy.java

示例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);
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:18,代码来源:AssetManager.java

示例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);
	}
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:26,代码来源:TmxMapLoader.java

示例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()));
}
 
开发者ID:pedja1,项目名称:SMC-Android,代码行数:21,代码来源:Assets.java

示例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;
}
 
开发者ID:MovementSpeed,项目名称:nhglib,代码行数:35,代码来源:NhgModelLoader.java

示例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();
    }
 
开发者ID:Longri,项目名称:cachebox3.0,代码行数:33,代码来源:ImageLoader.java

示例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;
}
 
开发者ID:varFamily,项目名称:cocos-ui-libgdx,代码行数:16,代码来源:CCTextureAtlasLoader.java

示例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);
}
 
开发者ID:broken-shotgun,项目名称:throw-the-moon,代码行数:38,代码来源:Player.java

示例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;
}
 
开发者ID:broken-shotgun,项目名称:throw-the-moon,代码行数:29,代码来源:Boss.java

示例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();
}
 
开发者ID:broken-shotgun,项目名称:throw-the-moon,代码行数:30,代码来源:StageClearScreen.java

示例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);
}
 
开发者ID:jsjolund,项目名称:GdxDemo3D,代码行数:9,代码来源:GameScene.java

示例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;
}
 
开发者ID:jsjolund,项目名称:GdxDemo3D,代码行数:13,代码来源:GameSceneManager.java


注:本文中的com.badlogic.gdx.assets.loaders.TextureLoader类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。