@Override public void loadAsync(AssetManager manager, String fileName, FileHandle file, TextureParameter parameter) { if (parameter == null || parameter.textureData == null) { Format format = null; boolean genMipMaps = false; info.texture = null; if (parameter != null) { format = parameter.format; genMipMaps = parameter.genMipMaps; info.texture = parameter.texture; } info.data = loadTexData(file, format, genMipMaps); } else { info.data = parameter.textureData; info.texture = parameter.texture; } if (!info.data.isPrepared()) { info.data.prepare(); } }
@Nullable @Override public Texture loadSync(AssetManager manager, String fileName, FileHandle file, TextureParameter parameter) { if (info == null) { return null; } Texture texture = info.texture; if (texture != null) { texture.load(info.data); } else { texture = new Texture(info.data); } if (parameter == null) { GdxTextureUtil.setDefaultTextureParams(texture); } else { texture.setFilter(parameter.minFilter, parameter.magFilter); texture.setWrap(parameter.wrapU, parameter.wrapV); } return texture; }
@Override @Nullable protected AssetLoaderParameters<Texture> getLoadParams(FilePath imagePath) { IImageDefinition imageDef = getImageDef(imagePath); if (imageDef == null) { return null; } TextureParameter params = new TextureParameter(); params.minFilter = GdxTextureUtil.toGdxFilter(imageDef.getMinifyFilter()); params.magFilter = GdxTextureUtil.toGdxFilter(imageDef.getMagnifyFilter()); params.wrapU = GdxTextureUtil.toGdxWrap(imageDef.getTilingModeX()); params.wrapV = GdxTextureUtil.toGdxWrap(imageDef.getTilingModeY()); return params; }
@Override public Array<AssetDescriptor> getDependencies(String fileName, FileHandle fileHandle, TiledMapParameter parameter) { try { map = new TiledMap(fileName, parameter.polyMode); } catch (Exception e) { logger.error("Failed loading tiled map", e); return null; } Array<AssetDescriptor> deps = new Array(); TextureParameter params = new TextureParameter(); params.format = parameter.format; params.genMipMaps = parameter.genMipMaps; params.minFilter = parameter.minFilter; params.magFilter = parameter.magFilter; params.wrapU = parameter.wrapU; params.wrapV = parameter.wrapV; IResourceLocator locator = CurrentResourceLocator.get(); for (TileSet tileset : map.getTileSets()) { TmxImage img = tileset.getImage(); String path = locator.combinePaths(tileset.getFilename(), img.getSource()); deps.add(new AssetDescriptor(path, Texture.class, params)); } return deps; }
/** 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); } }
@Override public Texture loadSync(AssetManager manager, String fileName, FileHandle file, TextureParameter parameter) { if (file instanceof URLFileHandle && parameter instanceof URLTextureParameter && ((URLTextureParameter) parameter).writePixmapTo != null) { if (pixmap != null) { Texture texture = new Texture(pixmap); pixmap.dispose(); pixmap = null; return texture; } else { return textureLoader.loadSync(manager, fileName, ((URLTextureParameter) parameter).writePixmapTo, parameter); } } else { return textureLoader.loadSync(manager, fileName, file, parameter); } }
@SuppressWarnings("rawtypes") @Nullable @Override public Array<AssetDescriptor> getDependencies(String fileName, FileHandle file, TextureParameter parameter) { return null; }
private void loadAssetLists() { TextureParameter param = new TextureParameter(); param.minFilter = param.magFilter = Texture.TextureFilter.Linear; assetManager.loadAssetList("data/json/images.json", Texture.class, param); assetManager.loadAssetList("data/json/sounds.json", Sound.class, null); assetManager.loadAssetList("data/json/music.json", Music.class, null); assetManager.loadAssetListWithParam("data/json/animations.json", AnimationExtended.class, AnimationExtendedLoader.AnimationExtendedParameter.class); BitmapFontParameter fontParam = new BitmapFontParameter(); fontParam.flip = true; assetManager.loadAssetList("data/json/fonts.json", BitmapFont.class, fontParam); }
@Override public Array<AssetDescriptor> getDependencies(String fileName, FileHandle file, AnimationExtendedParameter parameter) { Array<AssetDescriptor> deps = new Array(); TextureLoader.TextureParameter params = new TextureParameter(); params.format = parameter.format; params.genMipMaps = parameter.genMipMaps; params.minFilter = parameter.minFilter; params.magFilter = parameter.magFilter; params.wrapU = parameter.wrapU; params.wrapV = parameter.wrapV; deps.add(new AssetDescriptor(parameter.filename, Texture.class, params)); return deps; }
public TitleScreen(Sokobug myGame) { game = myGame; readyToSkip = false; TextureParameter param = new TextureParameter(); param.minFilter = TextureFilter.Linear; param.magFilter = TextureFilter.Linear; game.assetManager.load(Resources.BACKGROUNDS_TITLE.getPath(), Texture.class, param); game.assetManager.finishLoading(); titleImage = new Sprite(game.assetManager.get(Resources.BACKGROUNDS_TITLE.getPath(), Texture.class)); titleImage.setPosition(0.f, 0.f); pasedTimeCounter = 0.0f; titleScreenMinDuration = 3.5f; game.assetManager.load(Resources.FONTS_JAPONESA24.getPath(), BitmapFont.class); game.assetManager.load(Resources.FONTS_JAPONESA32.getPath(), BitmapFont.class); game.assetManager.load(Resources.FONTS_JAPONESA60.getPath(), BitmapFont.class); game.assetManager.load(Resources.FONTS_JAPONESA120.getPath(), BitmapFont.class); game.assetManager.load(Resources.UI_BUTTONS_PACK.getPath(), TextureAtlas.class); game.assetManager.load(Resources.UI_BUTTONS_JSON.getPath(), Skin.class, new SkinLoader.SkinParameter( Resources.UI_BUTTONS_PACK.getPath())); game.assetManager.load(Resources.BACKGROUNDS_MENU.getPath(), Texture.class, param); game.assetManager.load(Resources.BACKGROUNDS_POTATOES.getPath(), Texture.class, param); game.assetManager.load(Resources.ANIMATIONS_PACK_BUG.getPath(), TextureAtlas.class); game.assetManager.load(Resources.ANIMATIONS_PACK_SPOTGLOW.getPath(), TextureAtlas.class); game.assetManager.load(Resources.ANIMATIONS_PACK_VICTORYGLOW.getPath(), TextureAtlas.class); game.assetManager.load(Resources.TILES_SARCOPHAGUS.getPath(), Texture.class, param); game.assetManager.load(Resources.TILES_WALL.getPath(), Texture.class, param); game.assetManager.load(Resources.TILES_FREE.getPath(), Texture.class, param); game.assetManager.load(Resources.TILES_SPOTON.getPath(), Texture.class, param); game.assetManager.load(Resources.TILES_SPOTOFF.getPath(), Texture.class, param); game.assetManager.load(Resources.METAITEMS_TOPBAR.getPath(), Texture.class, param); game.assetManager.load(Resources.METAITEMS_PAD.getPath(), Texture.class, param); game.assetManager.load(Resources.METAITEMS_VICTORYWING.getPath(), Texture.class, param); game.assetManager.load(Resources.LABELS_FINISH.getPath(), Texture.class, param); game.assetManager.load(Resources.SOUND_BUGMOVE.getPath(), Sound.class); game.assetManager.load(Resources.SOUND_BUTTONCLICK.getPath(), Sound.class); game.assetManager.load(Resources.SOUND_SARCOPHAGUSMOVE.getPath(), Sound.class); game.assetManager.load(Resources.SOUND_VICTORY.getPath(), Sound.class); }
@Override public Array<AssetDescriptor> getDependencies(String fileName, FileHandle file, TextureParameter parameter) { return null; }