• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*******************************************************************************
2  * Copyright 2011 See AUTHORS file.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *   http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  ******************************************************************************/
16 
17 package com.badlogic.gdx.maps.tiled;
18 
19 import com.badlogic.gdx.assets.AssetManager;
20 import com.badlogic.gdx.graphics.Texture;
21 import com.badlogic.gdx.maps.Map;
22 import com.badlogic.gdx.utils.Array;
23 import com.badlogic.gdx.utils.Disposable;
24 
25 /** @brief Represents a tiled map, adds the concept of tiles and tilesets.
26  *
27  * @see Map */
28 public class TiledMap extends Map {
29 	private TiledMapTileSets tilesets;
30 	private Array<? extends Disposable> ownedResources;
31 
32 	/** @return collection of tilesets for this map. */
getTileSets()33 	public TiledMapTileSets getTileSets () {
34 		return tilesets;
35 	}
36 
37 	/** Creates an empty TiledMap. */
TiledMap()38 	public TiledMap () {
39 		tilesets = new TiledMapTileSets();
40 	}
41 
42 	/** Used by loaders to set resources when loading the map directly, without {@link AssetManager}. To be disposed in
43 	 * {@link #dispose()}.
44 	 * @param resources */
setOwnedResources(Array<? extends Disposable> resources)45 	public void setOwnedResources (Array<? extends Disposable> resources) {
46 		this.ownedResources = resources;
47 	}
48 
49 	@Override
dispose()50 	public void dispose () {
51 		if (ownedResources != null) {
52 			for (Disposable resource : ownedResources) {
53 				resource.dispose();
54 			}
55 		}
56 	}
57 }
58