本文整理汇总了Java中im.bci.tmxloader.TmxMap类的典型用法代码示例。如果您正苦于以下问题:Java TmxMap类的具体用法?Java TmxMap怎么用?Java TmxMap使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TmxMap类属于im.bci.tmxloader包,在下文中一共展示了TmxMap类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Map
import im.bci.tmxloader.TmxMap; //导入依赖的package包/类
public Map(File mapFile) throws IOException {
TmxLoader loader = new TmxLoader();
mTmxMap = new TmxMap();
loader.parseTmx(mTmxMap, loadText(mapFile));
loader.decode(mTmxMap);
mMapElements = new MapElement[mTmxMap.getHeight() * mTmxMap.getWidth()];
for (TmxLayer layer : mTmxMap.getLayers()) {
for (int x = 0; x < mTmxMap.getWidth(); ++x) {
for (int y = 0; y < mTmxMap.getHeight(); ++y) {
TmxTileInstance tile = layer.getTileAt(x, y);
if (tile != null) {
MapElement element = getMapElement(x, y);
if (element == null) {
element = new MapElement(x, y, mTmxMap.getTilewidth(), mTmxMap.getTileheight());
setMapElement(x, y, element);
}
if (!tile.getProperty("blocking", "false").equals("false")) {
element.setBlocking(true);
} else if (!tile.getProperty("player_spawn", "false").equals("false")) {
element.setSpawn(true);
mPlayerSpawnList.add(new Vector2f(x * mTmxMap.getTilewidth(), y * mTmxMap.getTileheight()));
}
Log.debug("MapElementProperty (" + x + ", " + y + ") Blocking: " + element.isBlocking()
+ ", Spawn: " + element.isSpawn());
// TODO add more properties
}
}
}
}
}
示例2: testFile
import im.bci.tmxloader.TmxMap; //导入依赖的package包/类
private void testFile(File mapFile) throws IOException {
final File mapParentDir = mapFile.getParentFile().getCanonicalFile();
TmxLoader loader = new TmxLoader();
TmxMap map = new TmxMap();
loader.parseTmx(map, loadText(mapFile));
for (TmxTileset tileset : map.getTilesets()) {
File tilesetParentDir;
if (null != tileset.getSource()) {
final File tilesetFile = new File(mapParentDir, tileset.getSource());
tilesetParentDir = tilesetFile.getParentFile().getCanonicalFile();
loader.parseTsx(map, tileset, loadText(tilesetFile));
} else {
tilesetParentDir = mapParentDir;
}
if (null != tileset.getImage()) {
tileset.getImage().setSource(
convertRelativeToAbsolutePath(tilesetParentDir, tileset.getImage().getSource()));
}
for (TmxTile tile : tileset.getTiles()) {
tile.getFrame()
.getImage()
.setSource(
convertRelativeToAbsolutePath(tilesetParentDir, tile.getFrame().getImage().getSource()));
}
}
loader.decode(map);
Assert.assertEquals(40, map.getWidth());
Assert.assertEquals(40, map.getHeight());
Assert.assertEquals(32, map.getTilewidth());
Assert.assertEquals(32, map.getTileheight());
Assert.assertEquals(1, map.getLayers().size());
// Test that the map was actually decoded. Tile at 0,0 has id 29.
Assert.assertEquals(29, map.getLayers().get(0).getTileAt(0, 0).getTile().getId());
}
示例3: loadTmx
import im.bci.tmxloader.TmxMap; //导入依赖的package包/类
public TmxAsset loadTmx(String mapFile) {
final String mapParentDir = mapFile.substring(0, mapFile.lastIndexOf('/') + 1);
TmxLoader loader = new TmxLoader();
TmxMap map = new TmxMap();
loader.parseTmx(map, assets.getText(mapFile));
for (TmxTileset tileset : map.getTilesets()) {
String tilesetParentDir;
if (null != tileset.getSource()) {
final String tilesetFile = mapParentDir + tileset.getSource();
tilesetParentDir = tilesetFile.substring(0, tilesetFile.lastIndexOf('/') + 1);
loader.parseTsx(map, tileset, assets.getText(tilesetFile));
} else {
tilesetParentDir = mapParentDir;
}
final TmxImage tilesetImage = tileset.getImage();
if (null != tilesetImage) {
tilesetImage.setSource(tilesetParentDir + tilesetImage.getSource());
}
for (TmxTile tile : tileset.getTiles()) {
final TmxImage tileImage = tile.getFrame().getImage();
if(tilesetImage != tileImage) {
tileImage.setSource(tilesetParentDir + tileImage.getSource());
}
}
}
loader.decode(map);
return new TmxAsset(assets, map);
}
示例4: getTmxMap
import im.bci.tmxloader.TmxMap; //导入依赖的package包/类
public TmxMap getTmxMap() {
return mTmxMap;
}
示例5: TmxAsset
import im.bci.tmxloader.TmxMap; //导入依赖的package包/类
public TmxAsset(IAssets assets, TmxMap map) {
this.assets = assets;
this.map = map;
}
示例6: getMap
import im.bci.tmxloader.TmxMap; //导入依赖的package包/类
public TmxMap getMap() {
return map;
}