當前位置: 首頁>>代碼示例>>Java>>正文


Java TiledMapTileLayer.getTileHeight方法代碼示例

本文整理匯總了Java中com.badlogic.gdx.maps.tiled.TiledMapTileLayer.getTileHeight方法的典型用法代碼示例。如果您正苦於以下問題:Java TiledMapTileLayer.getTileHeight方法的具體用法?Java TiledMapTileLayer.getTileHeight怎麽用?Java TiledMapTileLayer.getTileHeight使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.badlogic.gdx.maps.tiled.TiledMapTileLayer的用法示例。


在下文中一共展示了TiledMapTileLayer.getTileHeight方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: generateMap

import com.badlogic.gdx.maps.tiled.TiledMapTileLayer; //導入方法依賴的package包/類
@Override
public IMap<T> generateMap(TiledMap map) {
	tm = map;
	mainLayer = (TiledMapTileLayer) tm.getLayers().get(0);
	pixelwidth = (int) (mainLayer.getWidth() * mainLayer.getTileWidth());
	pixelheight = (int) (mainLayer.getHeight() * mainLayer.getTileHeight());
	int resolution = (int) mainLayer.getTileWidth();

	// generate the quad tree

	QuadTree<T> tree = new QuadTree<T>(resolution);
	QuadNode<T> headNode = generateSquare(0, 0, pixelwidth, pixelheight, tree, null);
	tree.root = headNode;

	headNode.genVisibilityGraph();

	return tree;
}
 
開發者ID:langurmonkey,項目名稱:rts-engine,代碼行數:19,代碼來源:QuadMapGen.java

示例2: ScrollMap

import com.badlogic.gdx.maps.tiled.TiledMapTileLayer; //導入方法依賴的package包/類
/**
 *
 * @param tileMap ширина, высота и размер тайла берется из первого слоя:
 * TiledMapTileLayer bg = (TiledMapTileLayer) tileMap.getLayers().get(0);
 * cellSize = (int) bg.getTileHeight(); mapW = bg.getWidth(); mapH =
 * bg.getHeight();
 */
public ScrollMap(TiledMap tileMap) {
    mapCamera = new OrthographicCamera();
    mapRenderer = new OrthogonalTiledMapRenderer(tileMap, 1f/* / cellSize */);
    stageViewport = new ScreenViewport(new OrthographicCamera());
    TiledMapTileLayer bg = (TiledMapTileLayer) tileMap.getLayers().get(0);
    cellSize = (int) bg.getTileHeight();
    mapW = bg.getWidth() * cellSize;
    mapH = bg.getHeight() * cellSize;
    mapHolder = new Actor();
    mapHolder.setSize(mapW, mapH);
    scrollPane = new ScrollPane(mapHolder);
    scrollPane.setOverscroll(false, false);
    root = new Table();
    root.setFillParent(true);
    root.add(scrollPane).fill().expand();
    stage = new Stage(stageViewport);
    stage.addActor(root);
    im = new InputMultiplexer();
    gameBatch = mapRenderer.getSpriteBatch();
    sprites = new Array<Sprite>();
    gestureDetector = new GestureDetector(gestureListener);
}
 
開發者ID:NaikSoftware,項目名稱:SaveUA,代碼行數:30,代碼來源:ScrollMap.java

示例3: parseMap

import com.badlogic.gdx.maps.tiled.TiledMapTileLayer; //導入方法依賴的package包/類
/**
 * Parst die Map.
 *
 * Wird von {@link #initMap()} aufgerufen.
 */
private void parseMap()
{
    TiledMapTileLayer firstLayer = (TiledMapTileLayer) tileMap.getLayers().get(0);

    mapWidth = firstLayer.getWidth() * firstLayer.getTileWidth();
    mapHeight = firstLayer.getHeight() * firstLayer.getTileHeight();

    parseMapObjects();
    parseMapCollisionTiles();
}
 
開發者ID:Entwicklerpages,項目名稱:school-game,代碼行數:16,代碼來源:Level.java

示例4: loadLevel

import com.badlogic.gdx.maps.tiled.TiledMapTileLayer; //導入方法依賴的package包/類
public void loadLevel(String level, boolean isServer, String name) {
    this.isServer = isServer;
    map = new TmxMapLoader().load(level);
    TiledMapTileLayer layer = (TiledMapTileLayer) map.
                                getLayers().get("terrain");
    VIEWPORT_WIDTH = (int) (layer.getTileWidth() * layer.getWidth());
    VIEWPORT_HEIGHT = (int) (layer.getTileHeight() * layer.getHeight());
    viewport = new FitViewport(VIEWPORT_WIDTH, VIEWPORT_HEIGHT, camera);
    renderer = new OrthogonalTiledMapRenderer(map);
    name = name.trim();
    if (name.length() == 0)
        name = "noname";
    if (name.length() >= 10){
        name = name.substring(0, 10);
    }
    ClientDetailsMessage clientDetails = new ClientDetailsMessage();
    clientDetails.name = name;
    clientDetails.protocolVersion = Constants.PROTOCOL_VERSION;
    if (isServer) {
        MapLayer collision =  map.
                getLayers().get("collision");
        for(MapObject object: collision.getObjects()) {
            worldManager.createWorldObject(object);
        }
        worldManager.addIncomingEvent(MessageObjectPool.instance.
                eventPool.obtain().set(State.RECEIVED, clientDetails));
    } else {
        client.sendTCP(clientDetails);
    }
    controls = new onScreenControls();
    
}
 
開發者ID:ganeshkamathp,項目名稱:killingspree,代碼行數:33,代碼來源:WorldRenderer.java

示例5: RTSAbstractMap

import com.badlogic.gdx.maps.tiled.TiledMapTileLayer; //導入方法依賴的package包/類
public RTSAbstractMap(RTSGame game, String tiledMapPath, boolean useFogOfWar) {
super();
this.game = game;

// Lets initialize the tiled map
tiledMap = new TmxMapLoader().load(tiledMapPath);

MapLayers mapLayers = tiledMap.getLayers();
baseLayer = (TiledMapTileLayer) mapLayers.get(BASE_LAYER_NAME);
baseLayerOverlay = (TiledMapTileLayer) mapLayers.get(BASE_LAYER_OVERLAY_NAME);
MapLayer objectsLayer = mapLayers.get(OBJECTS_LAYER_NAME);
if (objectsLayer != null)
    mapObjects = objectsLayer.getObjects();

mapBatch = new SpriteBatch(100, RTSGame.game.mapShader);

// Initialize map renderer
mapRenderer = new OrthogonalTiledMapRenderer(tiledMap, mapBatch);

initializeMapGenAndRenderer();

// And now let's initialize the quadtree
map = mapGen.generateMap(tiledMap);

astar = new AStar<IBoundsObject>(map);

// Number of tiles that fit in the canvas, to render.
renderTileWidth = Gdx.graphics.getWidth() / (int) baseLayer.getTileWidth();
renderTileHeight = Gdx.graphics.getHeight() / (int) baseLayer.getTileHeight();

// Fog of war
this.useFogOfWar = useFogOfWar;
if (useFogOfWar) {
    fogOfWar = new FogOfWar((int) (baseLayer.getWidth()), (int) (baseLayer.getHeight()),
	    (int) baseLayer.getTileWidth());
}
   }
 
開發者ID:langurmonkey,項目名稱:rts-engine,代碼行數:38,代碼來源:RTSAbstractMap.java

示例6: generateKeyEntity

import com.badlogic.gdx.maps.tiled.TiledMapTileLayer; //導入方法依賴的package包/類
protected Entity generateKeyEntity(TiledMapTileLayer layer, String keyName, boolean mirrored, float xOffset,
		float yOffset) {
	Vector2 keyLoc = findFirstCell(layer);

	if (keyLoc == null) {
		throw new IllegalArgumentException("Could not find key in layer \"" + layer.getName() + "\".");
	} else {
		Entity e = world.createEntity();

		Position position = world.createComponent(Position.class);
		position.position.x = keyLoc.x * layer.getTileWidth() + xOffset;
		position.position.y = keyLoc.y * layer.getTileHeight() + yOffset;
		e.addComponent(position);

		Collectable collectable = world.createComponent(Collectable.class);
		collectable.item = new Item(keyName, ItemType.KEY);
		e.addComponent(collectable);

		StaticSprite staticSprite = world.createComponent(StaticSprite.class);
		staticSprite.textureRegion = layer.getCell((int) keyLoc.x, (int) keyLoc.y).getTile().getTextureRegion();
		staticSprite.spriteWidth = staticSprite.textureRegion.getRegionWidth();
		staticSprite.spriteHeight = staticSprite.textureRegion.getRegionHeight();
		staticSprite.mirrored = mirrored;
		e.addComponent(staticSprite);

		Solid solid = world.createComponent(Solid.class);
		solid.boundingBox = new Rectangle(position.position.x, position.position.y, staticSprite.spriteWidth,
				staticSprite.spriteHeight);
		e.addComponent(solid);

		e.addToWorld();
		e.disable();
		return e;
	}
}
 
開發者ID:UoLCompSoc,項目名稱:mobius,代碼行數:36,代碼來源:LevelEntityFactory.java

示例7: generateExitEntity

import com.badlogic.gdx.maps.tiled.TiledMapTileLayer; //導入方法依賴的package包/類
protected Entity generateExitEntity(TiledMapTileLayer layer, boolean mirrored, float xOffset, float yOffset) {
	Vector2 exitLoc = findFirstCell(layer);

	if (exitLoc == null) {
		throw new IllegalArgumentException("Could not find exit in layer \"" + layer.getName() + "\".");
	} else {
		Entity e = world.createEntity();

		Position p = world.createComponent(Position.class);
		p.position.x = exitLoc.x * layer.getTileWidth() + xOffset;
		p.position.y = exitLoc.y * layer.getTileHeight() + xOffset;
		e.addComponent(p);

		Interactable i = world.createComponent(Interactable.class);
		e.addComponent(i);

		StaticSprite s = world.createComponent(StaticSprite.class);
		s.textureRegion = layer.getCell((int) exitLoc.x, (int) exitLoc.y).getTile().getTextureRegion();
		s.spriteWidth = s.textureRegion.getRegionWidth();
		s.spriteHeight = s.textureRegion.getRegionHeight();
		s.mirrored = mirrored;
		e.addComponent(s);

		Solid solid = world.createComponent(Solid.class);
		solid.boundingBox = new Rectangle(p.position.x, p.position.y, s.spriteWidth, s.spriteHeight);
		solid.invertedGravity = false;
		solid.weight = 0.25f;
		e.addComponent(solid);

		e.addToWorld();
		e.disable();
		return e;
	}
}
 
開發者ID:UoLCompSoc,項目名稱:mobius,代碼行數:35,代碼來源:LevelEntityFactory.java

示例8: RandomLevel

import com.badlogic.gdx.maps.tiled.TiledMapTileLayer; //導入方法依賴的package包/類
public RandomLevel(MySidekick parent, MsgHandler remote, World world) {
	super(parent, EMPTY_MAP_PATH, remote);
	TiledMapTileLayer tileLayer = (TiledMapTileLayer) map.getLayers().get(
			C.TileLayer);
	MapLayer objectLayer = map.getLayers().get(C.ObjectLayer);
	TILE_WIDTH = tileLayer.getTileWidth();
	TILE_HEIGHT = tileLayer.getTileHeight();
	generateLevel(map.getTileSets(), tileLayer, objectLayer, world);
}
 
開發者ID:tbporter,項目名稱:Cypher-Sydekick,代碼行數:10,代碼來源:RandomLevel.java

示例9: setup

import com.badlogic.gdx.maps.tiled.TiledMapTileLayer; //導入方法依賴的package包/類
public static final void setup(TiledMap map) {
	TiledMapTileLayer layer = (TiledMapTileLayer) map.getLayers().get(0);
	TILE_WIDTH = layer.getTileWidth();
	TILE_HEIGHT = layer.getTileHeight();
	TILES = map.getTileSets().getTileSet(0);
	mEntities = new ArrayList<Entity>(20);
}
 
開發者ID:tbporter,項目名稱:Cypher-Sydekick,代碼行數:8,代碼來源:Entity.java

示例10: getTileHeight

import com.badlogic.gdx.maps.tiled.TiledMapTileLayer; //導入方法依賴的package包/類
@Override
public float getTileHeight(TiledMapTileLayer layer) {
	return layer.getTileHeight() * unitScaleY;
}
 
開發者ID:mganzarcik,項目名稱:fabulae,代碼行數:5,代碼來源:OrthogonalGameMapRenderer.java

示例11: getTileHeight

import com.badlogic.gdx.maps.tiled.TiledMapTileLayer; //導入方法依賴的package包/類
@Override
public float getTileHeight(TiledMapTileLayer layer) {
	return layer.getTileHeight() * unitScaleY * 0.5f;
}
 
開發者ID:mganzarcik,項目名稱:fabulae,代碼行數:5,代碼來源:IsometricGameMapRenderer.java

示例12: generateMap

import com.badlogic.gdx.maps.tiled.TiledMapTileLayer; //導入方法依賴的package包/類
@Override
public IMap<T> generateMap(TiledMap map) {
	tm = map;
	mainLayer = (TiledMapTileLayer) tm.getLayers().get(RTSAbstractMap.BASE_LAYER_NAME);
	mainLayerOverlay = (TiledMapTileLayer) tm.getLayers().get(RTSAbstractMap.BASE_LAYER_OVERLAY_NAME);

	int columns = mainLayer.getWidth();
	int rows = mainLayer.getHeight();

	GridMap<T> gridMap = new GridMap<T>(columns, rows, (int) mainLayer.getTileWidth(),
			(int) mainLayer.getTileHeight());

	for (int col = 0; col < columns; col++) {
		for (int row = 0; row < rows; row++) {
			Cell cell = mainLayer.getCell(col, row);
			String type = cell.getTile().getProperties().get(PROPERTY_TYPE, "undefined", String.class);
			boolean shadow = Boolean.valueOf(cell.getTile().getProperties()
					.get(PROPERTY_SHADOW, "false", String.class));
			if (mainLayerOverlay != null) {
				// Check if there's an overlay
				Cell over = mainLayerOverlay.getCell(col, row);
				if (over != null && over.getTile() != null) {
					String typeaux = over.getTile().getProperties().get(PROPERTY_TYPE, "none", String.class);
					if (!typeaux.equals("none")) {
						type = typeaux;
					}
					if (Boolean.valueOf(over.getTile().getProperties().get(PROPERTY_SHADOW, "false", String.class))) {
						shadow = true;
					}
				}
			}
			gridMap.getCell(col, row).setTerrainType(MapProperties.getTerrainType(type));
			gridMap.getCell(col, row).setShadow(shadow);
			gridMap.getCell(col, row).slopev = -Integer.valueOf(cell.getTile().getProperties()
					.get(PROPERTY_SLOPEV, "0", String.class));
			gridMap.getCell(col, row).slopeh = Integer.valueOf(cell.getTile().getProperties()
					.get(PROPERTY_SLOPEH, "0", String.class));
		}
	}

	generateHeights(gridMap);

	return gridMap;
}
 
開發者ID:langurmonkey,項目名稱:rts-engine,代碼行數:45,代碼來源:GridMapGen.java


注:本文中的com.badlogic.gdx.maps.tiled.TiledMapTileLayer.getTileHeight方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。