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


Java TiledMap类代码示例

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


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

示例1: PathFindingSystem

import com.badlogic.gdx.maps.tiled.TiledMap; //导入依赖的package包/类
public PathFindingSystem(int mapHeight, int mapWidth, TiledMap tiledMap) {
    super(Family.all(PathComponent.class, TransformComponent.class).get());

    this.mapHeight = mapHeight;
    this.mapWidth = mapWidth;

    map = new TileType[mapWidth][mapHeight];

    TiledMapTileLayer path = (TiledMapTileLayer) tiledMap.getLayers().get("Path");
    TiledMapTileLayer rocks = (TiledMapTileLayer) tiledMap.getLayers().get("Rocks");
    TiledMapTileLayer bushes = (TiledMapTileLayer) tiledMap.getLayers().get("Bushes");

    for (int x = 0; x < map.length; x++) {
        for (int y = 0; y < map[x].length; y++) {
            if (path.getCell(x, y) != null) {
                map[x][y] = TileType.FLOOR;
            } else if (rocks.getCell(x, y) != null || bushes.getCell(x, y) != null) {
                map[x][y] = TileType.WALL;
            } else {
                map[x][y] = TileType.EMPTY;
            }
        }
    }
}
 
开发者ID:MiniDigger,项目名称:projecttd,代码行数:25,代码来源:PathFindingSystem.java

示例2: InteractiveTileObject

import com.badlogic.gdx.maps.tiled.TiledMap; //导入依赖的package包/类
public InteractiveTileObject(World world, TiledMap map, Rectangle bounds){
    this.world = world;
    this.map = map;
    this.bounds = bounds;

    BodyDef bdef = new BodyDef();
    FixtureDef fdef = new FixtureDef();
    PolygonShape shape = new PolygonShape();

    bdef.type = BodyDef.BodyType.StaticBody;
    bdef.position.set((bounds.getX() + bounds.getWidth() / 2) / NoObjectionGame.PPM, (bounds.getY() + bounds.getHeight() / 2 )/ NoObjectionGame.PPM);

    body = world.createBody(bdef);
    shape.setAsBox(bounds.getWidth() / 2 / NoObjectionGame.PPM, bounds.getHeight() / 2 / NoObjectionGame.PPM);
    fdef.shape = shape;
    fixture = body.createFixture(fdef);
}
 
开发者ID:MissionBit,项目名称:summer17-android,代码行数:18,代码来源:InteractiveTileObject.java

示例3: PlayState

import com.badlogic.gdx.maps.tiled.TiledMap; //导入依赖的package包/类
public PlayState(Server server, StateManager states)
{
	this.server = server;
	this.states = states;
	rewardForFisnishedQuestObserver = new RewardForFinishedQuestObserver(this, this);
	questEventsHandler = new EventsHandler(rewardForFisnishedQuestObserver);
	camera.setToOrtho(false);
	camera.viewportWidth = 3000;
	camera.viewportHeight = 1600;

	collisionMap.setScale(1);
	TiledMap map = loadMap();

	if (ServerSettings.isHeadless)
		mapRenderer = new NullOrthogonalTiledMapRenderer();
	else
		mapRenderer = new OrthogonalTiledMapRenderer(map, Assets.getBatch());

	Gdx.input.setInputProcessor(inputHandler);

	addNpcs();
	addGameObject(ObjectsIdentifiers.QUEST_BOARD, 100, 100);
}
 
开发者ID:MMORPG-Prototype,项目名称:MMORPG_Prototype,代码行数:24,代码来源:PlayState.java

示例4: loadFonts

import com.badlogic.gdx.maps.tiled.TiledMap; //导入依赖的package包/类
private void loadFonts(TiledMap data, String atlasname) {
	MapObjects objects = data.getLayers().get("preload").getObjects();
	String ffcheck = "Font";
	for (MapObject o : objects) {
		String name = o.getName();
		BitmapFont font = null;
		MapProperties properties = o.getProperties();
		String type = properties.get("type", String.class);
		String fontfile = properties.get("font_file", String.class);
		if (fontfile != null && type != null && type.equals(ffcheck)) {
			boolean markup = properties.get("markup", false, boolean.class);
			game.loadFont(fontfile, atlasname);
			game.getAssetManager().finishLoading();
			font = game.getFont(fontfile);
			fonts.put(name, font);
			font.getData().markupEnabled = markup;
		}
	}
}
 
开发者ID:kyperbelt,项目名称:KyperBox,代码行数:20,代码来源:GameState.java

示例5: loadParticleEffects

import com.badlogic.gdx.maps.tiled.TiledMap; //导入依赖的package包/类
private void loadParticleEffects(TiledMap data, String atlasname) {
	MapObjects objects = data.getLayers().get("preload").getObjects();
	String ppcheck = "Particle";
	for (MapObject o : objects) {
		String name = o.getName();
		MapProperties properties = o.getProperties();
		String type = properties.get("type", String.class);
		if (type != null && type.equals(ppcheck)) {
			String file = properties.get("particle_file", String.class);
			if (file != null) {
				game.loadParticleEffect(file, atlasname);
				game.getAssetManager().finishLoading();
				if (!particle_effects.containsKey(name)) {
					ParticleEffect pe = game.getParticleEffect(file);
					pe.setEmittersCleanUpBlendFunction(false);
					pvalues.add(KyperBoxGame.PARTICLE_FOLDER + KyperBoxGame.FILE_SEPARATOR + file);
					particle_effects.put(name, new ParticleEffectPool(pe, 12, 48));
				}
			}
		}
	}
}
 
开发者ID:kyperbelt,项目名称:KyperBox,代码行数:23,代码来源:GameState.java

示例6: loadShaders

import com.badlogic.gdx.maps.tiled.TiledMap; //导入依赖的package包/类
private void loadShaders(TiledMap data) {
	MapObjects objects = data.getLayers().get("preload").getObjects();
	String scheck = "Shader";
	for (MapObject o : objects) {
		String name = o.getName();
		MapProperties properties = o.getProperties();
		String type = properties.get("type", String.class);
		if (type != null && type.equals(scheck)) {
			String file = properties.get("shader_name", String.class);
			if (file != null) {
				game.loadShader(file);
				game.getAssetManager().finishLoading();
				if (!shaders.containsKey(name)) {
					ShaderProgram sp = game.getShader(file);
					shaders.put(name, sp);
					svalues.add(KyperBoxGame.SHADER_FOLDER + KyperBoxGame.FILE_SEPARATOR + file);
				}
			}
		}
	}
}
 
开发者ID:kyperbelt,项目名称:KyperBox,代码行数:22,代码来源:GameState.java

示例7: GameMap

import com.badlogic.gdx.maps.tiled.TiledMap; //导入依赖的package包/类
public GameMap(final OrthographicCamera camera, final TiledMap map,
               final TiledMapRenderer mapRenderer, final Location parentLocation) {
    this.camera = camera;
    this.map = map;
    this.mapRenderer = mapRenderer;
    this.parentLocation = parentLocation;
    mapLayers = new TreeMap<>();
    entities = new LinkedList<>();
    triggers = new LinkedList<>();
    tileTriggers = new HashMap<>();
    actionQueue = new LinkedList<>();
    animations = new LinkedList<>();
    mapEffects = new LinkedList<>();
    namedActors = new HashMap<>();
    doors = new HashMap<>();
    buildMapLayers(map);
    graphNodeIndex = new TileCoordinate[getNodeCount()];
}
 
开发者ID:JayStGelais,项目名称:jrpg-engine,代码行数:19,代码来源:GameMap.java

示例8: buildMapLayers

import com.badlogic.gdx.maps.tiled.TiledMap; //导入依赖的package包/类
private void buildMapLayers(final TiledMap map) {
    for (com.badlogic.gdx.maps.MapLayer mapLayer : map.getLayers()) {
        TiledMapTileLayer tiledMapLayer = (TiledMapTileLayer) mapLayer;

        if (tiledMapLayer.getProperties().containsKey(MAP_LAYER_PROP_MAP_LAYER)) {
            int mapLayerIndex = tiledMapLayer.getProperties().get(MAP_LAYER_PROP_MAP_LAYER, Integer.class);

            MapLayer gameMapLayer = mapLayers.computeIfAbsent(mapLayerIndex, i -> new MapLayer(i, mapRenderer));

            switch (tiledMapLayer.getProperties().get(MAP_LAYER_PROP_LAYER_TYPE, String.class)) {
                case MAP_LAYER_TYPE_BACKGRAOUND:
                    gameMapLayer.addBackgroundLayer(tiledMapLayer);
                    break;
                case MAP_LAYER_TYPE_FOREGRAOUND:
                    gameMapLayer.addForegroundLayer(tiledMapLayer);
                    break;
                case MAP_LAYER_TYPE_COLLISION:
                    gameMapLayer.setCollisionLayer(tiledMapLayer);
                    break;
                default:
            }
        }
    }
}
 
开发者ID:JayStGelais,项目名称:jrpg-engine,代码行数:25,代码来源:GameMap.java

示例9: getCellPropertyFromTopMostTile

import com.badlogic.gdx.maps.tiled.TiledMap; //导入依赖的package包/类
public static <T> T getCellPropertyFromTopMostTile(final TiledMap tiledMap, final TileCoordinate coordinate,
                                                   final String propertyName, final Class<T> clazz) {
    T value = null;
    for (MapLayer mapLayer : tiledMap.getLayers()) {
        if (mapLayer instanceof TiledMapTileLayer
                && matchProperty(mapLayer, GameMap.MAP_LAYER_PROP_MAP_LAYER, coordinate.getMapLayer())) {
            TiledMapTileLayer tiledMapTileLayer = (TiledMapTileLayer) mapLayer;
            TiledMapTileLayer.Cell cell = tiledMapTileLayer.getCell(coordinate.getX(), coordinate.getY());
            if (cell != null) {
                final MapProperties cellProps = cell.getTile().getProperties();
                value = (cellProps.get(propertyName, clazz) != null) ? cellProps.get(propertyName, clazz) : value;
            }
        }
    }

    return value;
}
 
开发者ID:JayStGelais,项目名称:jrpg-engine,代码行数:18,代码来源:TiledUtil.java

示例10: init

import com.badlogic.gdx.maps.tiled.TiledMap; //导入依赖的package包/类
public static void init() {

        assetManager.setLoader(TiledMap.class, new TmxMapLoader());

        for (Assets.Fonts font : Assets.Fonts.values()) {
            assetManager.load(font.getPath(), BitmapFont.class);
        }
        for (Assets.Textures texture : Assets.Textures.values()) {
            assetManager.load(texture.getPath(), Texture.class);
        }
        for (Assets.Maps map : Assets.Maps.values()) {
            assetManager.load(map.getPath(), TiledMap.class);
        }
        for (Assets.Musics music : Assets.Musics.values()) {
            assetManager.load(music.getPath(), Music.class);
        }
        for (Assets.Sounds sound : Assets.Sounds.values()) {
            assetManager.load(sound.getPath(), Sound.class);
        }
        assetManager.finishLoading();
    }
 
开发者ID:bitbrain,项目名称:rbcgj-2016,代码行数:22,代码来源:AssetManager.java

示例11: load

import com.badlogic.gdx.maps.tiled.TiledMap; //导入依赖的package包/类
public void load(TiledMap map) {
    MapProperties properties = map.getProperties();
    width = (Integer) properties.get(Tmx.WIDTH);
    height = (Integer) properties.get(Tmx.HEIGHT);
    objects = new MapObject[width][height];
    portals.clear();

    for (MapLayer layer : map.getLayers()) {
        for (MapObject object : layer.getObjects()) {
            if (object.getProperties().get("portal-id") != null) {
                portals.put((String) object.getProperties().get("portal-id"), object);
            }
            MapProperties objectProperties = object.getProperties();
            float x = (Float) objectProperties.get("x");
            float y = (Float) objectProperties.get("y");
            int indexX = (int) Math.floor(x / GameConfig.CELL_SCALE);
            int indexY = (int) Math.floor(y / GameConfig.CELL_SCALE);
            if (indexX >= 0 && indexY >= 0 && indexX < width && indexY < height) {
                objects[indexX][indexY] = object;
            }
        }
    }
}
 
开发者ID:bitbrain,项目名称:rbcgj-2016,代码行数:24,代码来源:MapActionHandler.java

示例12: initSolidTiles

import com.badlogic.gdx.maps.tiled.TiledMap; //导入依赖的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

示例13: prepareResources

import com.badlogic.gdx.maps.tiled.TiledMap; //导入依赖的package包/类
private void prepareResources(GameContext context) {
   TiledMap map = SharedAssetManager.getInstance().get(Assets.RPG.MAP_1, TiledMap.class);
   context.getRenderPipeline().set(RenderPipeIds.BACKGROUND,
         new TiledMapRenderer(map, (OrthographicCamera) context.getGameCamera().getInternal()));
   context.getLightingManager().setAmbientLight(new Color(0.1f, 0.05f, 0.3f, 0.4f));
   Texture texture = SharedAssetManager.getInstance().get(Assets.RPG.CHARACTER_TILESET);
   SpriteSheet sheet = new SpriteSheet(texture, 12, 8);
   createAnimations(context, sheet);

   factory = new NPCFactory(BLOCK_SIZE, context.getGameWorld());
   GameObject player = spawnObject(context, 10, 10, NPC.CITIZEN_MALE, new OrientationMovementController());
   context.getGameCamera().setTarget(player);
   final int NPCS = 25;

   for (int i = 0; i < NPCS; ++i) {
      int randomX = (int) (Math.random() * 25);
      int randomY = (int) (Math.random() * 25);
      spawnObject(context, randomX, randomY, NPC.random(), new RandomOrientationMovementController());
   }

   context.getLightingManager().addPointLight("lantern", 200, 200, 500, Color.valueOf("ff9955ff"));
}
 
开发者ID:bitbrain,项目名称:braingdx,代码行数:23,代码来源:RPGScreen.java

示例14: populate

import com.badlogic.gdx.maps.tiled.TiledMap; //导入依赖的package包/类
public void populate(TiledMap tiledMap, State state, Camera camera, MapLayerRendererFactory rendererFactory,
      TiledMapConfig config) {
   MapLayers mapLayers = tiledMap.getLayers();
   handleMapProperties(tiledMap.getProperties(), state, config);
   List<String> layerIds = new ArrayList<String>();
   int lastTileLayerIndex = 0;
   for (int i = 0; i < mapLayers.getCount(); ++i) {
      MapLayer mapLayer = mapLayers.get(i);
      if (mapLayer instanceof TiledMapTileLayer) {
         if (i > 0) {
            lastTileLayerIndex++;
         }
         String layerId = handleTiledMapTileLayer((TiledMapTileLayer) mapLayer, i, tiledMap, camera, rendererFactory,
               config);
         layerIds.add(layerId);
         populateStaticMapData(lastTileLayerIndex, (TiledMapTileLayer) mapLayer, state, config);
      } else {
         // Not a tiledlayer so consider it as an object layer
         handleObjectLayer(lastTileLayerIndex, mapLayer, state, config);
      }
   }
   state.setLayerIds(layerIds);
}
 
开发者ID:bitbrain,项目名称:braingdx,代码行数:24,代码来源:StatePopulator.java

示例15: load_withMapObjectsValidAPI

import com.badlogic.gdx.maps.tiled.TiledMap; //导入依赖的package包/类
@Test
public void load_withMapObjectsValidAPI() throws TiledMapException {
   final String type = "game_object";
   TiledMapListener listenerMock = mock(TiledMapListener.class);
   ArgumentCaptor<GameObject> gameObjectCaptor = ArgumentCaptor.forClass(GameObject.class);
   ArgumentCaptor<TiledMapAPI> apiCaptor = ArgumentCaptor.forClass(TiledMapAPI.class);
   Mockito.doNothing().when(listenerMock).onLoadGameObject(gameObjectCaptor.capture(), apiCaptor.capture());
   TiledMap map = new MockTiledMapBuilder(2, 2, 1).addLayer().addLayer()
         .addLayer(new MockObjectLayerBuilder().addObject(0, 0, type, false).addObject(1, 1, type).build())
         .addLayer().build();
   tiledMapManager.addListener(listenerMock);
   tiledMapManager.load(map, camera, TiledMapType.ORTHOGONAL);
   assertEquals(gameObjectCaptor.getAllValues().size(), 2);
   assertThat(apiCaptor.getValue()).isNotNull();
   assertThat(apiCaptor.getValue().getNumberOfColumns()).isEqualTo(2);
   assertThat(apiCaptor.getValue().getNumberOfRows()).isEqualTo(2);
   assertThat(apiCaptor.getValue().highestZIndexAt(0, 0)).isGreaterThan(2);
   assertThat(apiCaptor.getValue().isCollision(0, 0, 1)).isFalse();
   assertThat(apiCaptor.getValue().isCollision(1, 1, 1)).isTrue();
}
 
开发者ID:bitbrain,项目名称:braingdx,代码行数:21,代码来源:TiledMapManagerTest.java


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