public MemoryTrackingAssetManager(FileResolverMultiplexer fileResolverMultiplexer) { super(fileResolverMultiplexer); currentMemory = 0; memoryPerFile = new HashMap<String, Integer>(); eventBus = new SafeEventBus(MemoryTrackingAssetManager.class.getSimpleName()); setErrorListener(new AssetErrorListener() { @Override public void error(AssetDescriptor asset, Throwable throwable) { AssetLoadErrorEvent event = Pools.obtain(AssetLoadErrorEvent.class); event.setFileName(asset.fileName); event.setType(asset.type); events().post(event); Pools.free(event); } }); }
@Override public void create () { float w = Gdx.graphics.getWidth(); float h = Gdx.graphics.getHeight(); camera = new OrthographicCamera(); camera.setToOrtho(false, (w / h) * 10, 10); camera.zoom = 2; camera.update(); cameraController = new OrthoCamController(camera); Gdx.input.setInputProcessor(cameraController); font = new BitmapFont(); batch = new SpriteBatch(); AtlasTiledMapLoaderParameters params = new AtlasTiledMapLoaderParameters(); params.forceTextureFilters = true; params.textureMinFilter = TextureFilter.Linear; params.textureMagFilter = TextureFilter.Linear; assetManager = new AssetManager(); assetManager.setErrorListener(new AssetErrorListener() { @Override public void error (AssetDescriptor asset, Throwable throwable) { errorMessage = throwable.getMessage(); } }); assetManager.setLoader(TiledMap.class, new AtlasTmxMapLoader(new InternalFileHandleResolver())); assetManager.load(fileName, TiledMap.class); }
public Assets() { inst = this; manager = new AssetManager(); manager.setErrorListener(new AssetErrorListener() { @Override public void error(AssetDescriptor assetDescriptor, Throwable throwable) { Log.error(assetDescriptor.toString()); Log.error(throwable.getMessage()); } }); manager.getLogger().setLevel(Logger.DEBUG); }
public Assets(Files files) { setEnumNames(false); this.files = files; listeners = new Array<AssetLoadingListener>(); assetManager = new AssetManager(this); assetManager.setErrorListener(this); i18n = new I18N(this); setLoader(Skin.class, new ExtendedSkinLoader(this)); setLoader(Texture.class, new URLTextureLoader(this)); setLoader(SkeletonData.class, new SkeletonLoader(this)); assetManager.setErrorListener(new AssetErrorListener() { @Override public void error(AssetDescriptor asset, Throwable throwable) { AssetLoaderParameters params = asset.params; if (params != null) { LoadedCallback loadedCallback = params.loadedCallback; if (loadedCallback instanceof ErrorCallback) { ((ErrorCallback) loadedCallback).errored( asset.fileName, asset.type, throwable); } } else { Gdx.app.error("Assets", "Exception loading asset", throwable); } } }); }