本文整理汇总了Java中com.badlogic.gdx.maps.tiled.TiledMapTileSet类的典型用法代码示例。如果您正苦于以下问题:Java TiledMapTileSet类的具体用法?Java TiledMapTileSet怎么用?Java TiledMapTileSet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TiledMapTileSet类属于com.badlogic.gdx.maps.tiled包,在下文中一共展示了TiledMapTileSet类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initialize
import com.badlogic.gdx.maps.tiled.TiledMapTileSet; //导入依赖的package包/类
@Override
protected void initialize() {
super.initialize();
cableMask = mapSystem.getMask("cable-type");
for (TiledMapTileSet tileSet : mapSystem.map.getTileSets()) {
for (TiledMapTile tile : tileSet) {
MapProperties properties = tile.getProperties();
if (properties.containsKey("cable-type")) {
if ((Boolean) properties.get("cable-state")) {
tilesOn.put((Integer) properties.get("cable-type"), tile);
} else {
tilesOff.put((Integer) properties.get("cable-type"), tile);
}
}
}
}
}
示例2: tilesetNameFromTileId
import com.badlogic.gdx.maps.tiled.TiledMapTileSet; //导入依赖的package包/类
/** Returns the tileset name associated with the specified tile id
* @return a tileset name */
private String tilesetNameFromTileId (TiledMap map, int tileid) {
String name = "";
if (tileid == 0) {
return "";
}
for (TiledMapTileSet tileset : map.getTileSets()) {
int firstgid = tileset.getProperties().get("firstgid", -1, Integer.class);
if (firstgid == -1) continue; // skip this tileset
if (tileid >= firstgid) {
name = tileset.getName();
} else {
return name;
}
}
return name;
}
示例3: findTileFrames
import com.badlogic.gdx.maps.tiled.TiledMapTileSet; //导入依赖的package包/类
private void findTileFrames() {
for (TiledMapTileSet tileSet : tiledMap.getTileSets()) {
for (TiledMapTile tile : tileSet) {
final MapProperties tileProperties = tile.getProperties();
if (tileProperties.containsKey(JRPG_TILE_ANIMATION_ID)
&& tileProperties.get(JRPG_TILE_ANIMATION_ID).equals(id)) {
tileFrames.put(tileProperties.get(JRPG_TILE_ANIMATION_INDEX, Integer.class), tile);
}
}
}
}
示例4: Goban
import com.badlogic.gdx.maps.tiled.TiledMapTileSet; //导入依赖的package包/类
/**
* Create a new Goban
*
* @param screen Screen where this Goban lives.
* @param map The map to load for this Goban
*/
public Goban(GoGameScreen screen, TiledMap map) {
this.screen = screen;
this.map = screen.getMap();
gobanOriginCoords = new Vector2(Float.parseFloat(map.getProperties().get("goOriginX", String.class)),
Float.parseFloat(map.getProperties().get("goOriginY", String.class)));
final TiledMapTileSet stoneTS = map.getTileSets().getTileSet("stoneTS");
int firstGid = stoneTS.getProperties().get("firstgid", Integer.class);
this.blackStone = stoneTS.getTile(firstGid);
this.whiteStone = stoneTS.getTile(firstGid + 1);
this.gobanSize = Integer.parseInt(map.getProperties().get("gobanSize", String.class));
engineThread = generateGameThread();
}
示例5: setupMap
import com.badlogic.gdx.maps.tiled.TiledMapTileSet; //导入依赖的package包/类
/**
* Loads the map and sets up its display parameters
*/
private void setupMap() {
manager.load("com/ragego/gui/maps/" + getMapToLoad() + ".tmx", TiledMap.class);
manager.finishLoading();
Gdx.app.log(getClass().getCanonicalName(), "Map loaded");
map = manager.get("com/ragego/gui/maps/" + getMapToLoad() + ".tmx");
renderer = new IsometricTiledMapRenderer(map);
worldCamera = new OrthographicCamera();
gridLayer = (TiledMapTileLayer) map.getLayers().get("grid");
selection = (TiledMapTileLayer) map.getLayers().get("selection");
final TiledMapTileSet toolTS = map.getTileSets().getTileSet("toolTS");
selectionTile = toolTS.getTile(toolTS.getProperties().get("firstgid", Integer.class));
backgroundColor = new Color(GuiUtils.colorFromHexString(map.getProperties().get("backgroundcolor", String.class)));
}
示例6: TileSetLayout
import com.badlogic.gdx.maps.tiled.TiledMapTileSet; //导入依赖的package包/类
/** Constructs a Tile Set layout. The tile set image contained in the baseDir should be the original tile set images before
* being processed by {@link TiledMapPacker} (the ones actually read by Tiled).
* @param tileset the tile set to process
* @param baseDir the directory in which the tile set image is stored */
protected TileSetLayout (int firstgid, TiledMapTileSet tileset, FileHandle baseDir) throws IOException {
int tileWidth = tileset.getProperties().get("tilewidth", Integer.class);
int tileHeight = tileset.getProperties().get("tileheight", Integer.class);
int margin = tileset.getProperties().get("margin", Integer.class);
int spacing = tileset.getProperties().get("spacing", Integer.class);
this.firstgid = firstgid;
image = ImageIO.read(baseDir.child(tileset.getProperties().get("imagesource", String.class)).read());
imageTilePositions = new IntMap<Vector2>();
// fill the tile regions
int x, y, tile = 0;
numRows = 0;
numCols = 0;
int stopWidth = image.getWidth() - tileWidth;
int stopHeight = image.getHeight() - tileHeight;
for (y = margin; y <= stopHeight; y += tileHeight + spacing) {
for (x = margin; x <= stopWidth; x += tileWidth + spacing) {
if (y == margin) numCols++;
imageTilePositions.put(tile, new Vector2(x, y));
tile++;
}
numRows++;
}
numTiles = numRows * numCols;
}
示例7: getTile
import com.badlogic.gdx.maps.tiled.TiledMapTileSet; //导入依赖的package包/类
public static TiledMapTile getTile(final TiledMap tiledMap, final String tilesetName, final int tileId) {
final TiledMapTileSet tileset = tiledMap.getTileSets().getTileSet(tilesetName);
return (tileset != null)
? tileset.getTile(tileset.getProperties().get(FISRTGID_PARAM, Integer.class) + tileId)
: null;
}
示例8: getTileSet
import com.badlogic.gdx.maps.tiled.TiledMapTileSet; //导入依赖的package包/类
public TiledMapTileSet getTileSet(String name) {
return tiledMap.getTileSets().getTileSet(name);
}
示例9: packTilesets
import com.badlogic.gdx.maps.tiled.TiledMapTileSet; //导入依赖的package包/类
/** Traverse the specified tilesets, optionally lookup the used ids and pass every tile image to the {@link TexturePacker},
* optionally ignoring unused tile ids */
private void packTilesets (ObjectMap<String, TiledMapTileSet> sets, FileHandle inputDirHandle, File outputDir,
Settings texturePackerSettings) throws IOException {
BufferedImage tile;
Vector2 tileLocation;
TileSetLayout packerTileSet;
Graphics g;
packer = new TexturePacker(texturePackerSettings);
for (TiledMapTileSet set : sets.values()) {
String tilesetName = set.getName();
System.out.println("Processing tileset " + tilesetName);
IntArray usedIds = this.settings.stripUnusedTiles ? getUsedIdsBucket(tilesetName, -1) : null;
int tileWidth = set.getProperties().get("tilewidth", Integer.class);
int tileHeight = set.getProperties().get("tileheight", Integer.class);
int firstgid = set.getProperties().get("firstgid", Integer.class);
String imageName = set.getProperties().get("imagesource", String.class);
TileSetLayout layout = new TileSetLayout(firstgid, set, inputDirHandle);
for (int gid = layout.firstgid, i = 0; i < layout.numTiles; gid++, i++) {
if (usedIds != null && !usedIds.contains(gid)) {
System.out.println("Stripped id #" + gid + " from tileset \"" + tilesetName + "\"");
continue;
}
tileLocation = layout.getLocation(gid);
tile = new BufferedImage(tileWidth, tileHeight, BufferedImage.TYPE_4BYTE_ABGR);
g = tile.createGraphics();
g.drawImage(layout.image, 0, 0, tileWidth, tileHeight, (int)tileLocation.x, (int)tileLocation.y, (int)tileLocation.x
+ tileWidth, (int)tileLocation.y + tileHeight, null);
if (isBlended(tile)) setBlended(gid);
System.out.println("Adding " + tileWidth + "x" + tileHeight + " (" + (int)tileLocation.x + ", " + (int)tileLocation.y
+ ")");
packer.addImage(tile, this.settings.atlasOutputName + "_" + (gid-1));
}
}
File outputDirTilesets = getRelativeFile(outputDir, this.settings.tilesetOutputDirectory);
outputDirTilesets.mkdirs();
packer.pack(outputDirTilesets, this.settings.atlasOutputName + ".atlas");
}