You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I'm developing a 2D game using a Tilemap built with Tiled. The Tilemap display is fine, but I would like to create water animations at two points on the map by fetching the object layer coordinates from the tmx file (my tilemap file). I manage to get the object, its co-ordinates and the size of the object, but when it comes to displaying the texture, the texture is not displayed at all, without any error message.
Reproduction steps/code
privatestaticfinalintTILESET_COLS = 26, TILESET_ROWS = 15, TILE_WIDTH = 32, TILE_HEIGHT = 32;
privateAssetManagerassetManager;
privateTiledMapmap;
privateTexturetileSheet;
privateOrthogonalTiledMapRenderertilemapRenderer;
// CameraprivateOrthographicCameracamera;
privateSpriteBatchbatch;
privateBitmapFontfont;
// Animation des chûtes d'eauprivateAnimation<TextureRegion> waterFallAnimation;
privateList<Rectangle> waterFallRectangles = newLinkedList<Rectangle>();
privatefloat_waterFallStateTime = 0;
@Overridepublicvoidcreate() {
batch = newSpriteBatch();
assetManager = newAssetManager();
assetManager.setLoader(TiledMap.class, newTmxMapLoader(newInternalFileHandleResolver()));
assetManager.load("Map.tmx", TiledMap.class);
assetManager.finishLoading();
map = assetManager.get("Map.tmx");
// Rendu de la maptilemapRenderer = newOrthogonalTiledMapRenderer(map);
// Mettre la fenêtre en mode plein écranGdx.graphics.setFullscreenMode(Gdx.graphics.getDisplayMode());
// Mise en place de la caméra dans la scènecamera = newOrthographicCamera();
camera.setToOrtho(false, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
camera.update();
// Rendre le fenêtre redimensionnableGdx.graphics.setResizable(true);
// Chargement de l'animation des chûtes d'eautileSheet = newTexture(Gdx.files.internal("Tiles/32x32.png"));
TextureRegion[][] waterFallTmp = TextureRegion.split(tileSheet, TILE_WIDTH, TILE_HEIGHT);
TextureRegion[] waterFallFrames = newTextureRegion[3];
waterFallFrames[0] = waterFallTmp[10][14];
waterFallFrames[1] = waterFallTmp[10][15];
waterFallFrames[2] = waterFallTmp[10][16];
waterFallAnimation = newAnimation<TextureRegion>(0.150f, waterFallFrames);
// Récupération du groupe d'object LayersMapGroupLayerobjectsGroupLayer = (MapGroupLayer) map.getLayers().get("ObjectsLayers");
// Récupération de l'object Layer "Waterfall"MapLayerwaterFallLayer = objectsGroupLayer.getLayers().get("Waterfall");
// Récupération des objets de l'object Layer "Waterfall"MapObjectswaterFallObjects = waterFallLayer.getObjects();
for (MapObjectobject : waterFallObjects) {
RectangleMapObjectrectangleMapObject = (RectangleMapObject) object;
waterFallRectangles.add(rectangleMapObject.getRectangle());
}
}
@Overridepublicvoidrender() {
ScreenUtils.clear(0, 0, 0, 1);
camera.setToOrtho(false, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
camera.update();
tilemapRenderer.setView(camera);
tilemapRenderer.render();
// Gestion de l'animation des chûtes d'eau_waterFallStateTime += Gdx.graphics.getDeltaTime();
TextureRegioncurrentFrame = waterFallAnimation.getKeyFrame(_waterFallStateTime, true);
batch.begin();
for (Rectanglerectangle : waterFallRectangles)
batch.draw(currentFrame, rectangle.x, rectangle.y, rectangle.width, rectangle.height);
batch.end();
}
Version of libGDX and/or relevant dependencies
Latest
Please select the affected platforms
Android
iOS
HTML/GWT
Windows
Linux
macOS
The text was updated successfully, but these errors were encountered:
Hi, I'm developing a 2D game using a Tilemap built with Tiled. The Tilemap display is fine, but I would like to create water animations at two points on the map by fetching the object layer coordinates from the tmx file (my tilemap file). I manage to get the object, its co-ordinates and the size of the object, but when it comes to displaying the texture, the texture is not displayed at all, without any error message.
Reproduction steps/code
Version of libGDX and/or relevant dependencies
Latest
Please select the affected platforms
The text was updated successfully, but these errors were encountered: