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; } } } }
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); }
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); }
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; } } }
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)); } } } } }
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); } } } } }
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()]; }
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: } } } }
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; }
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(); }
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; } } } }
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; } } } }
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")); }
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); }
@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(); }
public OrthogonalTiledMapRendererWithObjects(TiledMap map) { super(map); this.occlusionFbo = new FrameBuffer(Format.RGBA8888, Gdx.graphics.getWidth() / 2, Gdx.graphics.getHeight() / 2, false); this.shadowmapFbo = new FrameBuffer(Format.RGBA8888, Gdx.graphics.getWidth() / 2, 1, false); this.shadowmapTex = shadowmapFbo.getColorBufferTexture(); this.shadowmapTex.setFilter(TextureFilter.Linear, TextureFilter.Linear); this.shadowmapTex.setWrap(TextureWrap.Repeat, TextureWrap.Repeat); //this.orthoCam = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); //this.orthoCam.setToOrtho(Y_DOWN); this.lights = new ArrayList<Light>(); this.mouseLight = new Light(0, 0, Color.WHITE); }
@DirtiesContext @Test public void testLoadTiledMap () { setup(); TiledMap map = mapRegistry.getRegisteredMaps().get("testMap"); Assert.assertNotNull (map); TiledMapInfo info = new TiledMapInfo (map); assertEquals (102, info.getMapHeight()); assertEquals (105, info.getMapWidth()); assertEquals (64, info.getTileWidth()); assertEquals (64, info.getTileHeight()); assertEquals (32, info.getTileHalfHeight()); assertEquals (32, info.getTileHalfWidth()); assertEquals (map, info.getMap()); }
@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; }
/** Returns the tileset name associated with the specified tile id * @return a tileset name */ private String tilesetNameFromTileId (TiledMap map, int tileid) { String name = ""; if (tileid == 0) { return ""; } for (TiledMapTileSet tileset : map.getTileSets()) { int firstgid = tileset.getProperties().get("firstgid", -1, Integer.class); if (firstgid == -1) continue; // skip this tileset if (tileid >= firstgid) { name = tileset.getName(); } else { return name; } } return name; }
@Override public void create () { float w = Gdx.graphics.getWidth(); float h = Gdx.graphics.getHeight(); camera = new OrthographicCamera(); camera.setToOrtho(false, (w / h) * 10, 10); camera.zoom = 2; camera.update(); cameraController = new OrthoCamController(camera); Gdx.input.setInputProcessor(cameraController); font = new BitmapFont(); batch = new SpriteBatch(); assetManager = new AssetManager(); assetManager.setLoader(TiledMap.class, new TmxMapLoader(new InternalFileHandleResolver())); assetManager.load("data/maps/tiled/isometric_grass_and_water.tmx", TiledMap.class); assetManager.finishLoading(); map = assetManager.get("data/maps/tiled/isometric_grass_and_water.tmx"); renderer = new IsometricTiledMapRenderer(map, 1f / 64f); }
@Override public void create () { float w = Gdx.graphics.getWidth(); float h = Gdx.graphics.getHeight(); camera = new OrthographicCamera(); camera.setToOrtho(false, (w / h) * 10, 10); camera.zoom = 2; camera.update(); cameraController = new OrthoCamController(camera); Gdx.input.setInputProcessor(cameraController); font = new BitmapFont(); batch = new SpriteBatch(); assetManager = new AssetManager(); assetManager.setLoader(TiledMap.class, new TideMapLoader(new InternalFileHandleResolver())); assetManager.load("data/maps/tide/Map01.tide", TiledMap.class); assetManager.finishLoading(); map = assetManager.get("data/maps/tide/Map01.tide"); renderer = new OrthogonalTiledMapRenderer(map, 1f / 32f); }
/** * * @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); }
public static TiledMap genVoidMap(int w, int h) { ImpassableCells.clear(); tileAtlas = ResKeeper.get(AtlasId.MAP_TILES); TiledMap map = new TiledMap(); MapLayers layers = map.getLayers(); TiledMapTileLayer layerBg = new TiledMapTileLayer(w, h, CELL_SIZE, CELL_SIZE); MapCell cell = getCell(TileCode.GRASS, true); for (int i = 0; i < w; i++) { for (int j = 0; j < h; j++) { layerBg.setCell(i, j, cell); } } layers.add(layerBg); cells.clear(); return map; }
public EditGameMap(TiledMap tiledMap, String name, Array<Sprite> sprites) { this.tiledMap = tiledMap; this.name = name; Set<Integer> gamers = new HashSet<Integer>(); for (Sprite s : sprites) { if (s instanceof MapUnit) { MapUnit u = (MapUnit) s; units.add(u); if (u.getGamer() != null) {// if gamer == null - its a free unit gamers.add(u.getGamer().getId()); } } else if (s instanceof MapObject) { objects.add((MapObject) s); } } maxGamers = gamers.size(); }
protected Entity generateLevelEntity(TiledMap map, float x, float y) { Entity e = world.createEntity(); Position p = world.createComponent(Position.class); p.position.set(x, y); e.addComponent(p); TiledRenderable r = world.createComponent(TiledRenderable.class); r.map = map; r.renderer = new OrthogonalTiledMapRenderer(r.map, 1.0f, batch); r.renderableLayers = new String[3]; r.renderableLayers[0] = "floor"; r.renderableLayers[1] = "levelnumber"; r.renderableLayers[2] = "text"; e.addComponent(r); e.addToWorld(); e.disable(); return e; }
public static TiledMap generateInvertedMap(TiledMap map) { TiledMap invertedMap = new TiledMap(); MapLayers invertedLayers = invertedMap.getLayers(); for (int i = 0; i < map.getLayers().getCount(); i++) { TiledMapTileLayer origLayer = (TiledMapTileLayer) map.getLayers().get(i); TiledMapTileLayer tempLayer = invertLayer(origLayer); tempLayer.setOpacity(origLayer.getOpacity()); tempLayer.setName(origLayer.getName()); tempLayer.setVisible(origLayer.isVisible()); copyLayerProperties(origLayer, tempLayer); invertedLayers.add(tempLayer); } return invertedMap; }
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); } } } }
private static boolean loadNonBlocking(){ if(!readinglock){ clear(); loadAssets(); readinglock = true; } // once update returns true then condition is satisfied and the lock stops update call if(!updatinglock) if(assetMan.update()){ assetMan.setLoader(TiledMap.class, new TmxMapLoader(new InternalFileHandleResolver())); getAssets(); updatinglock = true; if(Scene.splashDuration != 0) Scene.nextSceneWithDelay(Scene.splashDuration); else Scene.nextScene(); } return updatinglock; }
private void loadAssetsGame() { Gdx.app.log(Constants.LOG, "Load ResourcesManager Game"); this.load(DEFAULT_FONT, BitmapFont.class); this.load(DEBUG_FONT, BitmapFont.class); this.load(HEADER_FONT, BitmapFont.class); this.load(DEBUG_BACKGROUND, Texture.class); this.load(MENU_BACKGROUND, Texture.class); this.load(STATS_BACKGROUND, Texture.class); this.load(SPRITE_ATLAS, TextureAtlas.class); this.load(VARIOS_ATLAS, TextureAtlas.class); this.load(OBJECTS_ATLAS, TextureAtlas.class); this.load(GUI_ATLAS, TextureAtlas.class); this.load(GUI_PACK_ATLAS, TextureAtlas.class); this.load(UISKIN_ATLAS, TextureAtlas.class); this.load(PARTICLE_EFFECT, ParticleEffect.class); this.load(PARTICLE_EFFECT_CONTACT, ParticleEffect.class); this.setLoader(TiledMap.class, new TmxMapLoader(new InternalFileHandleResolver())); this.load(MUSIC_MENU,Music.class); }
/** * Function responsible for loading the next available Map. * * @return True if no errors occurred and a map was loaded, false otherwise. */ private Boolean loadNextMap() { if (currentLevel == game.getNumMaps()) return false; TiledMap map = game.getAssetManager().get(game.getMap(currentLevel++), TiledMap.class); model.loadMap(map); if (mapRenderer != null) mapRenderer.setMap(map); return true; }
public GameTester(String map_name) { TiledMap testmap = new TmxMapLoader().load(map_name); model = new GameModel(testmap); //For positions and other stuff initialization noMotionDuringTime(0); }
private static void addClassTypes() { classTypes.put("png", Texture.class); classTypes.put("jpg", Texture.class); classTypes.put("bmp", Texture.class); classTypes.put("gif", Texture.class); classTypes.put("mp3", Music.class); classTypes.put("ogg", Sound.class); classTypes.put("tmx", TiledMap.class); }
private TiledMap loadMap() { TiledMap map = Assets.get("Map/tiled2.tmx"); loadCollision(map); loadSpawners(map); return map; }
public LogicMap(TiledMap map) { this.width = map.getProperties().get("width", Integer.class); this.height = map.getProperties().get("height", Integer.class); this.map = new Tile[width][height]; TiledMapTileLayer bottom = (TiledMapTileLayer) map.getLayers().get(0); for (int x = 0; x < width; x++) for (int y = 0; y < height; y++) { this.map[x][y] = Tile.fromCell(bottom.getCell(x, height - 1 - y), x, y); } }
@Override public void create() { game_prefs = Gdx.app.getPreferences(prefs_name); game_stage = new Stage(view); game_states = new ObjectMap<String, GameState>(); game_stage.setDebugAll(false); current_gamestates = new Array<GameState>(); transition_state = new GameState(null); transition_state.setGame(this); assets = new AssetManager(); assets.setLoader(TiledMap.class, new KyperMapLoader(assets.getFileHandleResolver())); assets.setLoader(ParticleEffect.class, new ParticleEffectLoader(assets.getFileHandleResolver())); assets.setLoader(ShaderProgram.class, new ShaderProgramLoader(assets.getFileHandleResolver(), VERTEX_SUFFIX, FRAGMENT_SUFFIX)); sound = new SoundManager(this); packages = new Array<String>(); packages.add("com.kyperbox.objects"); global_data = new UserData(GAME_DATA_NAME); input = new GameInput(); Gdx.input.setInputProcessor(game_stage); initiate(); }
public TiledMap load(String fileName, AtlasTiledMapLoaderParameters parameter) { try { if (parameter != null) { convertObjectToTileSpace = parameter.convertObjectToTileSpace; flipY = parameter.flipY; } else { convertObjectToTileSpace = false; flipY = true; } FileHandle tmxFile = resolve(fileName); root = xml.parse(tmxFile); ObjectMap<String, TextureAtlas> atlases = new ObjectMap<String, TextureAtlas>(); FileHandle atlasFile = Gdx.files .internal(KyperBoxGame.IMAGE_FOLDER + KyperBoxGame.FILE_SEPARATOR + KyperBoxGame.GAME_ATLAS); if (atlasFile == null) { throw new GdxRuntimeException("Couldn't load atlas"); } TextureAtlas atlas = new TextureAtlas(atlasFile); atlases.put(atlasFile.path(), atlas); AtlasResolver.DirectAtlasResolver atlasResolver = new AtlasResolver.DirectAtlasResolver(atlases); TiledMap map = loadMap(root, tmxFile, atlasResolver); map.setOwnedResources(atlases.values().toArray()); setTextureFilters(parameter.textureMinFilter, parameter.textureMagFilter); return map; } catch (IOException e) { throw new GdxRuntimeException("Couldn't load tilemap '" + fileName + "'", e); } }
@Override public TiledMap loadSync(AssetManager manager, String fileName, FileHandle file, com.badlogic.gdx.maps.tiled.AtlasTmxMapLoader.AtlasTiledMapLoaderParameters parameter) { if (parameter != null) { setTextureFilters(parameter.textureMinFilter, parameter.textureMagFilter); } return map; }
/** * Inititalisierung. * * @param map die Map, die gerendert werden soll * @param displayLayer der Layer in der Map, in dem auch die Objekte gerendert werden */ public ExtendedOrthogonalTiledMapRenderer (TiledMap map, TiledMapTileLayer displayLayer) { super(map); this.displayLayer = displayLayer; this.displayObjects = new Array<ExtendedMapDisplayObject>(false, 20); this.renderObjects = new Array<ExtendedMapDisplayObject>(true, 20); this.depthComparator = new DepthComparator(); }
protected final GameMap loadMap(final GraphicsService graphicsService, final AssetManager assetManager, final String mapPath, final Location parentLocation) { if (!assetManager.isLoaded(mapPath, TiledMap.class)) { assetManager.load(mapPath, TiledMap.class); assetManager.finishLoading(); } TiledMap tiledMap = assetManager.get(mapPath); TiledMapRenderer mapRenderer = graphicsService.getTileMapRenderer(tiledMap); return new GameMap(graphicsService.getCamera(), tiledMap, mapRenderer, parentLocation); }