com.badlogic.gdx.graphics.g2d
Class PolygonRegionLoader

java.lang.Object
  extended by com.badlogic.gdx.assets.loaders.AssetLoader<T,P>
      extended by com.badlogic.gdx.assets.loaders.SynchronousAssetLoader<PolygonRegion,PolygonRegionLoader.PolygonRegionParameters>
          extended by com.badlogic.gdx.graphics.g2d.PolygonRegionLoader

public class PolygonRegionLoader
extends SynchronousAssetLoader<PolygonRegion,PolygonRegionLoader.PolygonRegionParameters>

loads PolygonRegions using a PolygonRegionLoader

Author:
dermetfan

Nested Class Summary
static class PolygonRegionLoader.PolygonRegionParameters
           
 
Constructor Summary
PolygonRegionLoader()
           
PolygonRegionLoader(FileHandleResolver resolver)
           
 
Method Summary
 Array<AssetDescriptor> getDependencies(String fileName, FileHandle file, PolygonRegionLoader.PolygonRegionParameters params)
          If the PSH file contains a line starting with params.texturePrefix, an AssetDescriptor for the file referenced on that line will be added to the returned Array.
 PolygonRegion load(AssetManager manager, String fileName, FileHandle file, PolygonRegionLoader.PolygonRegionParameters parameter)
           
 PolygonRegion load(TextureRegion textureRegion, FileHandle file)
          Loads a PolygonRegion from a PSH (Polygon SHape) file.
 
Methods inherited from class com.badlogic.gdx.assets.loaders.AssetLoader
resolve
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PolygonRegionLoader

public PolygonRegionLoader()

PolygonRegionLoader

public PolygonRegionLoader(FileHandleResolver resolver)
Method Detail

load

public PolygonRegion load(AssetManager manager,
                          String fileName,
                          FileHandle file,
                          PolygonRegionLoader.PolygonRegionParameters parameter)
Specified by:
load in class SynchronousAssetLoader<PolygonRegion,PolygonRegionLoader.PolygonRegionParameters>

getDependencies

public Array<AssetDescriptor> getDependencies(String fileName,
                                              FileHandle file,
                                              PolygonRegionLoader.PolygonRegionParameters params)
If the PSH file contains a line starting with params.texturePrefix, an 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 params.textureExtensions will be used. If no suitable file is found, the returned Array will be empty.

Specified by:
getDependencies in class AssetLoader<PolygonRegion,PolygonRegionLoader.PolygonRegionParameters>
Parameters:
fileName - name of the asset to load
file - the resolved file to load
params - parameters for loading the asset
Returns:
other assets that the asset depends on and need to be loaded first or null if there are no dependencies.

load

public PolygonRegion load(TextureRegion textureRegion,
                          FileHandle file)
Loads a PolygonRegion from a PSH (Polygon SHape) file. The PSH file format defines the polygon vertices before triangulation:

s 200.0, 100.0, ...

Lines not prefixed with "s" are ignored. PSH files can be created with external tools, eg:
https://code.google.com/p/libgdx-polygoneditor/
http://www.codeandweb.com/physicseditor/

Parameters:
file - file handle to the shape definition file


Copyright © 2014. All Rights Reserved.