Refine search
/** @throws GdxRuntimeException if the element has no children. */ public Element getChild (int index) { if (children == null) throw new GdxRuntimeException("Element has no children: " + name); return children.get(index); }
throw new GdxRuntimeException("Error parsing external tileset."); FileHandle atlasFile = tmxFile.sibling(tmxFile.nameWithoutExtension() + ".atlas"); if (atlasFile.exists()) atlasFilePath = atlasFile.name(); throw new GdxRuntimeException("The map is missing the 'atlas' property"); trackedTextures.add(texture); regionName = regionName.substring(0, regionName.lastIndexOf('.')); AtlasRegion region = atlas.findRegion(regionName); if (region == null) throw new GdxRuntimeException("Tileset region not found: " + regionName); tile = new StaticTiledMapTile(region); tile.setId(tileid); Array<AnimatedTiledMapTile> animatedTiles = new Array<AnimatedTiledMapTile>(); if (animationElement != null) { Array<StaticTiledMapTile> staticTiles = new Array<StaticTiledMapTile>(); IntArray intervals = new IntArray(); for (Element frameElement: animationElement.getChildrenByName("frame")) {
private void loadImages (ParticleEmitter emitter) { String imagePath = null; try { Array<Sprite> sprites = new Array<Sprite>(); Array<String> imagePaths = emitter.getImagePaths(); for (int i = 0; i < imagePaths.size; i++) { imagePath = imagePaths.get(i); String imageName = new File(imagePath.replace('\\', '/')).getName(); FileHandle file; if ((imagePath.contains("/") || imagePath.contains("\\")) && !imageName.contains("..")) { file = Gdx.files.absolute(imagePath); if (!file.exists()) { sprites.add(new Sprite(new Texture(file))); ex.printStackTrace(); final String imagePathFinal = imagePath; EventQueue.invokeLater(new Runnable() {
@Override public Array<AssetDescriptor> getDependencies (String fileName, FileHandle tmxFile, Parameters parameter) { Array<AssetDescriptor> dependencies = new Array<AssetDescriptor>(); try { root = xml.parse(tmxFile); for (FileHandle image : loadTileSheets(root, tmxFile)) { dependencies.add(new AssetDescriptor(image.path(), Texture.class)); } return dependencies; } catch (IOException e) { throw new GdxRuntimeException("Couldn't load tilemap '" + fileName + "'", e); } }
/** If the PSH file contains a line starting with {@link PolygonRegionParameters#texturePrefix params.texturePrefix}, an * {@link AssetDescriptor} for the file referenced on that line will be added to the returned Array. Otherwise a sibling of the * given file with the same name and the first found extension in {@link PolygonRegionParameters#textureExtensions * params.textureExtensions} will be used. If no suitable file is found, the returned Array will be empty. */ @Override public Array<AssetDescriptor> getDependencies (String fileName, FileHandle file, PolygonRegionParameters params) { if (params == null) params = defaultParameters; String image = null; try { BufferedReader reader = file.reader(params.readerBuffer); for (String line = reader.readLine(); line != null; line = reader.readLine()) if (line.startsWith(params.texturePrefix)) { image = line.substring(params.texturePrefix.length()); break; } reader.close(); } catch (IOException e) { throw new GdxRuntimeException("Error reading " + fileName, e); } if (image == null && params.textureExtensions != null) for (String extension : params.textureExtensions) { FileHandle sibling = file.sibling(file.nameWithoutExtension().concat("." + extension)); if (sibling.exists()) image = sibling.name(); } if (image != null) { Array<AssetDescriptor> deps = new Array<AssetDescriptor>(1); deps.add(new AssetDescriptor<Texture>(file.sibling(image), Texture.class)); return deps; } return null; }
public void loadEmitters (FileHandle effectFile) { InputStream input = effectFile.read(); emitters.clear(); BufferedReader reader = null; try { reader = new BufferedReader(new InputStreamReader(input), 512); while (true) { ParticleEmitter emitter = newEmitter(reader); emitters.add(emitter); if (reader.readLine() == null) break; } } catch (IOException ex) { throw new GdxRuntimeException("Error loading effect: " + effectFile, ex); } finally { StreamUtils.closeQuietly(reader); } }
@Override public BitmapFont loadSync (AssetManager manager, String fileName, FileHandle file, BitmapFontParameter parameter) { if (parameter != null && parameter.atlasName != null) { TextureAtlas atlas = manager.get(parameter.atlasName, TextureAtlas.class); String name = file.sibling(data.imagePaths[0]).nameWithoutExtension().toString(); AtlasRegion region = atlas.findRegion(name); if (region == null) throw new GdxRuntimeException("Could not find font region " + name + " in atlas " + parameter.atlasName); return new BitmapFont(file, region); } else { int n = data.getImagePaths().length; Array<TextureRegion> regs = new Array(n); for (int i = 0; i < n; i++) { regs.add(new TextureRegion(manager.get(data.getImagePath(i), Texture.class))); } return new BitmapFont(data, regs, true); } }
public TextureAtlasData (FileHandle packFile, FileHandle imagesDir, boolean flip) { BufferedReader reader = new BufferedReader(new InputStreamReader(packFile.read()), 64); try { Page pageImage = null; pageImage = null; else if (pageImage == null) { FileHandle file = imagesDir.child(line); pages.add(pageImage); } else { boolean rotate = Boolean.valueOf(readValue(reader)); regions.add(region); throw new GdxRuntimeException("Error reading pack file: " + packFile, ex); } finally { StreamUtils.closeQuietly(reader); regions.sort(indexComparator);
public Bezier set (final Array<T> points, final int offset, final int length) { if (length < 2 || length > 4) throw new GdxRuntimeException("Only first, second and third degree Bezier curves are supported."); if (tmp == null) tmp = points.get(0).cpy(); if (tmp2 == null) tmp2 = points.get(0).cpy(); if (tmp3 == null) tmp3 = points.get(0).cpy(); this.points.clear(); this.points.addAll(points, offset, length); return this; }
public void addMesh (ModelMesh mesh) { for (ModelMesh other : meshes) { if (other.id.equals(mesh.id)) { throw new GdxRuntimeException("Mesh with id '" + other.id + "' already in model"); } } meshes.add(mesh); } }
TextureAtlasData textureAtlasData = new TextureAtlasData(new FileHandle(packFile), new FileHandle(packFile), false); for (Page page : pages) { for (Rect rect : page.outputRects) { for (Region region : textureAtlasData.getRegions()) { if (region.name.equals(rectName)) { throw new GdxRuntimeException( "A region with the name \"" + rectName + "\" has already been packed: " + rect.name); writer.write("repeat: " + getRepeatValue() + "\n"); page.outputRects.sort(); for (Rect rect : page.outputRects) { writeRect(writer, page, rect, rect.name); Array<Alias> aliases = new Array(rect.aliases.toArray()); aliases.sort(); for (Alias alias : aliases) { Rect aliasRect = new Rect();
public InputStream read () { if (type == FileType.Internal) { try { return assets.open(file.getPath()); } catch (IOException ex) { throw new GdxRuntimeException("Error reading file: " + file + " (" + type + ")", ex); } } return super.read(); }
public static void verifyCorrectness (Dummy d, int k) { enemy.sort(distComp); int idx = enemy.indexOf(d, true); // remember that k = min value = 0 position in the array, therefore k - 1 if (enemy.get(idx) != enemy.get(k - 1)) { System.out.println("origin dummy: " + originDummy); System.out.println("TEST FAILURE: " + "idx: " + idx + " does not equal (k - 1): " + (k - 1)); throw new GdxRuntimeException("test failed"); } }
public Bezier set (final T[] points, final int offset, final int length) { if (length < 2 || length > 4) throw new GdxRuntimeException("Only first, second and third degree Bezier curves are supported."); if (tmp == null) tmp = points[0].cpy(); if (tmp2 == null) tmp2 = points[0].cpy(); if (tmp3 == null) tmp3 = points[0].cpy(); this.points.clear(); this.points.addAll(points, offset, length); return this; }
/** Deletes this file or empty directory and returns success. Will not delete a directory that has children. * @throws GdxRuntimeException if this file handle is a {@link FileType#Classpath} or {@link FileType#Internal} file. */ public boolean delete () { if (type == FileType.Classpath) throw new GdxRuntimeException("Cannot delete a classpath file: " + file); if (type == FileType.Internal) throw new GdxRuntimeException("Cannot delete an internal file: " + file); return file().delete(); }
/** Loads the {@link TiledMap} from the given file. The file is resolved via the {@link FileHandleResolver} set in the * constructor of this class. By default it will resolve to an internal file. * @param fileName the filename * @param parameters specifies whether to use y-up, generate mip maps etc. * @return the TiledMap */ public TiledMap load (String fileName, TmxMapLoader.Parameters parameters) { try { this.convertObjectToTileSpace = parameters.convertObjectToTileSpace; this.flipY = parameters.flipY; FileHandle tmxFile = resolve(fileName); root = xml.parse(tmxFile); ObjectMap<String, Texture> textures = new ObjectMap<String, Texture>(); Array<FileHandle> textureFiles = loadTilesets(root, tmxFile); textureFiles.addAll(loadImages(root, tmxFile)); for (FileHandle textureFile : textureFiles) { Texture texture = new Texture(textureFile, parameters.generateMipMaps); texture.setFilter(parameters.textureMinFilter, parameters.textureMagFilter); textures.put(textureFile.path(), texture); } DirectImageResolver imageResolver = new DirectImageResolver(textures); TiledMap map = loadTilemap(root, tmxFile, imageResolver); map.setOwnedResources(textures.values().toArray()); return map; } catch (IOException e) { throw new GdxRuntimeException("Couldn't load tilemap '" + fileName + "'", e); } }
public OpenALSound newSound (FileHandle file) { if (file == null) throw new IllegalArgumentException("file cannot be null."); Class<? extends OpenALSound> soundClass = extensionToSoundClass.get(file.extension().toLowerCase()); if (soundClass == null) throw new GdxRuntimeException("Unknown file extension for sound: " + file); try { return soundClass.getConstructor(new Class[] {OpenALAudio.class, FileHandle.class}).newInstance(this, file); } catch (Exception ex) { throw new GdxRuntimeException("Error creating sound " + soundClass.getName() + " for file: " + file, ex); } }
static public FileHandle tempFile (String prefix) { try { return new FileHandle(File.createTempFile(prefix, null)); } catch (IOException ex) { throw new GdxRuntimeException("Unable to create temp file.", ex); } }
/** Begin building a new model */ public void begin () { if (model != null) throw new GdxRuntimeException("Call end() first"); node = null; model = new Model(); builders.clear(); }
static private void copyFile (FileHandle source, FileHandle dest) { try { dest.write(source.read(), false); } catch (Exception ex) { throw new GdxRuntimeException("Error copying source file: " + source.file + " (" + source.type + ")\n" // + "To destination: " + dest.file + " (" + dest.type + ")", ex); } }