当前位置: 首页>>代码示例>>Java>>正文


Java Cell类代码示例

本文整理汇总了Java中com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell的典型用法代码示例。如果您正苦于以下问题:Java Cell类的具体用法?Java Cell怎么用?Java Cell使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Cell类属于com.badlogic.gdx.maps.tiled.TiledMapTileLayer包,在下文中一共展示了Cell类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createTileLayerCell

import com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell; //导入依赖的package包/类
protected Cell createTileLayerCell (boolean flipHorizontally, boolean flipVertically, boolean flipDiagonally) {
	Cell cell = new mg.fishchicken.maps.Cell();
	if (flipDiagonally) {
		if (flipHorizontally && flipVertically) {
			cell.setFlipHorizontally(true);
			cell.setRotation(Cell.ROTATE_270);
		} else if (flipHorizontally) {
			cell.setRotation(Cell.ROTATE_270);
		} else if (flipVertically) {
			cell.setRotation(Cell.ROTATE_90);
		} else {
			cell.setFlipVertically(true);
			cell.setRotation(Cell.ROTATE_270);
		}
	} else {
		cell.setFlipHorizontally(flipHorizontally);
		cell.setFlipVertically(flipVertically);
	}
	return cell;
}
 
开发者ID:mganzarcik,项目名称:fabulae,代码行数:21,代码来源:TiledMapLoader.java

示例2: initSolidTiles

import com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell; //导入依赖的package包/类
private void initSolidTiles(TiledMap map){
	TiledMapTileLayer layer = (TiledMapTileLayer) map.getLayers().get("CollisionTiles");
	
	for(int x = 0; x < layer.getWidth(); x++){
		for(int y = 0; y < layer.getHeight(); y++){
			Cell cell = layer.getCell(x, y);
			if(cell == null){
				solids[x][y] = false;
				continue;
			}
			if(cell.getTile() == null){
				solids[x][y] = false;
				continue;
			}
			else{
				solids[x][y] = true;
			}
		}
	}
}
 
开发者ID:Portals,项目名称:DropTheCube-LD32,代码行数:21,代码来源:MapControllerSystem.java

示例3: initBlocks

import com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell; //导入依赖的package包/类
private void initBlocks(WorldTypeEnum background) {
	
	blocks = new ArrayList<AbstractBlock>();
	wallBlocks = new ArrayList<WallBlock>();

	for (int i = 0; i < tileLayer.getWidth(); i++) {
		for (int j = 0; j < tileLayer.getHeight(); j++) {
			Cell cell = tileLayer.getCell(i, j);
			if (cell != null) {
				TiledMapTile tile = cell.getTile();
				int id = tile.getId();
				
				BlockTypeEnum blockTypeEnum = TileIdConstants.getSpecialBlockType(id);
				if (blockTypeEnum==BlockTypeEnum.MYSTERY_BLOCK) {
					blocks.add(new MysteryBlock(i, j, id, background));
				} else if (blockTypeEnum==BlockTypeEnum.WALL_BLOCK) {
					wallBlocks.add(new WallBlock(i, j, id, background));
				} else if (blockTypeEnum==BlockTypeEnum.MYSTERY_BLOCK_INVISIBLE) {
					blocks.add(new InvisibleMysteryBlock(i, j, id, background));
				} 					
			}
		}
	}
}
 
开发者ID:provenza24,项目名称:Mario-Libgdx,代码行数:25,代码来源:TmxMap.java

示例4: CastleLevelEndingSceneHandler

import com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell; //导入依赖的package包/类
public CastleLevelEndingSceneHandler(Mario mario, TmxMap tileMap, GameCamera camera,
		 Array<IScrollingBackground> scrollingBbackgrounds, BitmapFont font, SpriteBatch spriteBatch,
		OrthogonalTiledMapRenderer renderer, Stage stage, Batch batch) {
	super(mario, tileMap, camera, scrollingBbackgrounds, font, spriteBatch, renderer, stage, batch);
	for (int i = 0; i < tileMap.getTileLayer().getWidth(); i++) {
		for (int j = 0; j < tileMap.getTileLayer().getHeight(); j++) {
			Cell cell = tileMap.getTileLayer().getCell(i, j);
			if (cell != null) {
				TiledMapTile tile = cell.getTile();
				int id = tile.getId();
				if (id==118) {
					tileToRemove.add(new Vector2(i,j));
				}
			}
		}
	}	
	for (AbstractEnemy enemy : tileMap.getEnemies()) {
		if (enemy.getEnemyType()==EnemyTypeEnum.BOWSER) {
			if (!enemy.isKilled()) {
				bowser = enemy;					
			} 
		}
	}
	updateEnemies = true;		
}
 
开发者ID:provenza24,项目名称:Mario-Libgdx,代码行数:26,代码来源:CastleLevelEndingSceneHandler.java

示例5: findStartPosition

import com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell; //导入依赖的package包/类
public Vector2 findStartPosition(){

		Vector2 start = null;
		Cell temp;
		//tile width and height = 32, so multiple width and height to get the area
		//add stepx and stepy by 32 to move between each tile
		for(int y = 0; y < tiles.getHeight(); y++){
			for(int x = 0; x < tiles.getWidth(); x++){
				temp = tiles.getCell(x, y);
				if( temp != null && temp.getTile().getProperties().containsKey("start")){
					start = new Vector2((x * tiles.getTileWidth()), (y * tiles.getTileHeight()));
					break;
				}
			}
			if(start != null){
				break;
			}
		}
		if(start == null){
			System.out.println("could not find start position");
		}
		return start;
	}
 
开发者ID:n-chunky,项目名称:TTmath,代码行数:24,代码来源:EntityManager.java

示例6: retrieveItem

import com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell; //导入依赖的package包/类
private String retrieveItem() {
	Cell cell = collisionLayer.getCell((int)(this.pos.x/tileWidth), (int)(this.pos.y/tileHeight));
	if(cell != null){
		String item = null;
		Iterator<String> obj = cell.getTile().getProperties().getKeys();
		while(obj.hasNext()){
			item = obj.next();
		}
		System.out.println(item);
		collisionLayer.setCell((int)(this.pos.x/tileWidth), (int)(this.pos.y/tileHeight), null);
		return item;
	}
	else {
		System.out.println("current tile has no items on it");
		return "null";
	}
}
 
开发者ID:n-chunky,项目名称:TTmath,代码行数:18,代码来源:Player.java

示例7: createTileLayerCell

import com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell; //导入依赖的package包/类
protected Cell createTileLayerCell (boolean flipHorizontally, boolean flipVertically, boolean flipDiagonally) {
	Cell cell = new Cell();
	if (flipDiagonally) {
		if (flipHorizontally && flipVertically) {
			cell.setFlipHorizontally(true);
			cell.setRotation(Cell.ROTATE_270);
		} else if (flipHorizontally) {
			cell.setRotation(Cell.ROTATE_270);
		} else if (flipVertically) {
			cell.setRotation(Cell.ROTATE_90);
		} else {
			cell.setFlipVertically(true);
			cell.setRotation(Cell.ROTATE_270);
		}
	} else {
		cell.setFlipHorizontally(flipHorizontally);
		cell.setFlipVertically(flipVertically);
	}
	return cell;
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:21,代码来源:BaseTmxMapLoader.java

示例8: SelectPanelCell

import com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell; //导入依赖的package包/类
/**
   * Конструктор для создания тайлов на панель в редакторе
   *
   * @param cell
   * @param size
   */
  public SelectPanelCell(Cell cell) {
      super();
      this.cell = cell;
      TextureRegionDrawable d = new TextureRegionDrawable(cell.getTile().getTextureRegion());
      setDrawable(d);
float size = d.getMinHeight();
      setOrigin(size / 2, size / 2);

      switch (cell.getRotation()) {
          case Cell.ROTATE_90:
              setRotation(90);
              break;
          case Cell.ROTATE_180:
              setRotation(180);
              break;
          case Cell.ROTATE_270:
              setRotation(270);
              break;
          default:
              break;
      }
  }
 
开发者ID:NaikSoftware,项目名称:SaveUA,代码行数:29,代码来源:SelectPanelCell.java

示例9: loadMap

import com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell; //导入依赖的package包/类
public static void loadMap(String fileName) {
	TiledMap map = new TmxMapLoader().load(fileName);
	for (int i = 0; i < map.getLayers().getCount(); i++) {
		TiledMapTileLayer layer = (TiledMapTileLayer) map.getLayers()
				.get(i);
		for (int x = 0; x < layer.getWidth(); x++) {
			for (int y = 0; y < layer.getHeight(); y++) {
				Cell cell = layer.getCell(x, layer.getHeight() - 1 - y);
				if (cell == null) {
					continue;
				}
				Entity e = EntityManager.createTile((String) cell.getTile()
						.getProperties().get("name"), x * 16, y * 16);
				EntityManager.setEntityLayer(e, Name.LAYER_FLOOR);
			}
		}
	}
}
 
开发者ID:Teascade,项目名称:Shadow-of-Goritur,代码行数:19,代码来源:MapLoader.java

示例10: getTilesPosition

import com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell; //导入依赖的package包/类
/**
 * Obtiene la lista de celdas de interés en las que está situado el jugador
 * Ahora mismo sólo comprueba las celdas de las casas
 * @param startX
 * @param startY
 * @param endX
 * @param endY
 * @param tiles
 */
private void getTilesPosition(int startX, int startY, int endX, int endY, Array<Rectangle> tiles) {
	
	tiles.clear();

	for (int y = startY; y <= endY; y++) {
		for (int x = startX; x <= endX; x++) {
			int xCell = (int) (x / collisionLayer.getTileWidth());
			int yCell = (int) (y / collisionLayer.getTileHeight());
			Cell cell = collisionLayer.getCell(xCell, yCell);
			
			// Si es un bloque se añade para comprobar colisiones
			if ((cell != null) && (cell.getTile().getProperties().containsKey("house"))) {
				Rectangle rect = rectPool.obtain();
				rect.set((int) (Math.ceil(x / 16f) * 16), (int) (Math.ceil(y / 16f) * 16), 0, 0);
				tiles.add(rect);
			}
		}
	}
}
 
开发者ID:sfaci,项目名称:libgdx,代码行数:29,代码来源:SpriteManager.java

示例11: getTilesPosition

import com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell; //导入依赖的package包/类
/**
 * Obtiene una lista de celdas con las que colisiona el item
 * @param startX
 * @param startY
 * @param endX
 * @param endY
 * @return
 */
private void getTilesPosition(int startX, int startY, int endX, int endY, Array<Rectangle> tiles) {
	
	tiles.clear();

	for (int y = startY; y <= endY; y++) {
		for (int x = startX; x <= endX; x++) {
			int xCell = (int) (x / TiledMapManager.collisionLayer.getTileWidth());
			int yCell = (int) (y / TiledMapManager.collisionLayer.getTileHeight());
			Cell cell = TiledMapManager.collisionLayer.getCell(xCell, yCell);
			
			// Si es un bloque se a�ade para comprobar colisiones
			if ((cell != null) && (cell.getTile().getProperties().containsKey(TiledMapManager.BLOCKED))) {
				Rectangle rect = rectPool.obtain();
				
				rect.set((int) (Math.ceil(x / 16f) * 16), (int) (Math.ceil(y / 16f) * 16), 0, 0);
				tiles.add(rect);
			}
		}
	}
}
 
开发者ID:sfaci,项目名称:libgdx,代码行数:29,代码来源:Item.java

示例12: getTilesPosition

import com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell; //导入依赖的package包/类
/**
 * Obtiene una lista de celdas con las que colisiona el enemigo
 * @param startX
 * @param startY
 * @param endX
 * @param endY
 * @return
 */
private void getTilesPosition(int startX, int startY, int endX, int endY, Array<Rectangle> tiles) {
	
	tiles.clear();

	for (int y = startY; y <= endY; y++) {
		for (int x = startX; x <= endX; x++) {
			int xCell = (int) (x / TiledMapManager.collisionLayer.getTileWidth());
			int yCell = (int) (y / TiledMapManager.collisionLayer.getTileHeight());
			Cell cell = TiledMapManager.collisionLayer.getCell(xCell, yCell);
			
			// Si es un bloque se a�ade para comprobar colisiones
			if ((cell != null) && (cell.getTile().getProperties().containsKey(TiledMapManager.BLOCKED))) {
				Rectangle rect = rectPool.obtain();
				
				rect.set((int) (Math.ceil(x / 16f) * 16), (int) (Math.ceil(y / 16f) * 16), 0, 0);
				tiles.add(rect);
			}
		}
	}
}
 
开发者ID:sfaci,项目名称:libgdx,代码行数:29,代码来源:Enemy.java

示例13: loadLayer

import com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell; //导入依赖的package包/类
public void loadLayer(int layerNo){
	Scene.log("Tiles Layer no: "+layerNo);
	TiledMapTileLayer layer = (TiledMapTileLayer)mlayers.get(layerNo);
	NoOfColumns = layer.getWidth();
	Scene.log("MapColumns: "+NoOfColumns);
	NoOfRows = layer.getHeight();
	Scene.log("MapRows: "+NoOfRows);
	tiles .add(new MapActor[NoOfRows][NoOfColumns]);
	for(int i=0; i<NoOfRows; i++)
		for(int j=0; j<NoOfColumns; j++){
			Cell c = layer.getCell(j, i);
			if(c != null){
				tiles.get(layerNo)[i][j] = new MapActor(c.getTile().getTextureRegion(),
						i, j, c.getTile().getId(), tileSize);
				addActor(tiles.get(layerNo)[i][j]);
			}
			else{
				tiles.get(layerNo)[i][j] = new MapActor((TextureRegion)null,i, j, 0, tileSize);
				addActor(tiles.get(layerNo)[i][j]);
			}
	}
	mapWidth = tileSize * NoOfColumns;
	mapHeight = tileSize * NoOfRows;
	//Stage.mapOffsetX = mapWidth - Stage.camOffsetX;
	//Stage.mapOffsetY = mapHeight - Stage.camOffsetYTop;
}
 
开发者ID:pyros2097,项目名称:GdxStudio,代码行数:27,代码来源:Map.java

示例14: generateHoles

import com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell; //导入依赖的package包/类
private void generateHoles() {
	Random r = new Random();
	int counter = 0;
	
	for (int x = 0; x < pathLayer.getWidth(); ++x)
		for (int y = 0; y < pathLayer.getHeight(); ++y) {
			Cell cell = pathLayer.getCell(x, y);
			if (cell == null)
				continue;		
			else if (cell.getTile().getProperties().containsKey("path")) {
				int num = r.nextInt(10 - 1 + 1) + 1;
				if (num >= 9) {
					++counter;
					if (counter <= 4)
						cell.setTile(holeTile);
				}
				else
					counter = 0;
			}
		}
}
 
开发者ID:adrianoubk,项目名称:Missing_Words,代码行数:22,代码来源:World.java

示例15: animateTiles

import com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell; //导入依赖的package包/类
/**
 * Make the tiles containing 'animation' key animated.
 * @param layer
 */
private void animateTiles(TiledMapTileLayer layer) {
	for (int x = 1; x < layer.getWidth(); x++) {
		for (int y = 1; y < layer.getHeight(); y++) {
			Cell cell = layer.getCell(x, y);
			if(cell != null) {
				TiledMapTile oldTile = cell.getTile();
				if(oldTile.getProperties().containsKey("animation")) {
					String animation = (String) oldTile.getProperties().get("animation");
					float speed = 0.15f;
					if(oldTile.getProperties().containsKey("speed")) {
						speed = Float.parseFloat((String) oldTile.getProperties().get("speed"));
					}
					AnimatedTiledMapTile newTile = new AnimatedTiledMapTile(speed, 
							Tiles.getAnimatedTile(animation));
					newTile.getProperties().putAll(oldTile.getProperties());
					cell.setTile(newTile);
				}
			}
		}
	}
}
 
开发者ID:arjanfrans,项目名称:mario-game,代码行数:26,代码来源:World.java


注:本文中的com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。