本文整理汇总了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;
}
示例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;
}
}
}
}
示例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));
}
}
}
}
}
示例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;
}
示例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;
}
示例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";
}
}
示例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;
}
示例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;
}
}
示例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);
}
}
}
}
示例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);
}
}
}
}
示例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);
}
}
}
}
示例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);
}
}
}
}
示例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;
}
示例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;
}
}
}
示例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);
}
}
}
}
}