SHOW:
|
|
- or go back to the newest paste.
1 | - | private Iterator<TiledMapTile> tiles; |
1 | + | |
2 | - | private Array<StaticTiledMapTile> frameTiles = new Array<StaticTiledMapTile>(); |
2 | + | private TiledMapTileLayer backgroundLayer; |
3 | ||
4 | - | private TiledMapTileLayer backgroundLayer; |
4 | + | private void animateTile(float delayBetweenAnimation, String tileSet, String tileToAnimate) { |
5 | Array<StaticTiledMapTile> frameTiles = new Array<StaticTiledMapTile>(); | |
6 | Iterator<TiledMapTile> tiles = map.getTileSets().getTileSet(tileSet).iterator(); | |
7 | - | private void animateTile(float delayBetweenAnimation, String tileSet, String tileToAnimate){ |
7 | + | |
8 | - | frameTiles.clear(); |
8 | + | while(tiles.hasNext()) { |
9 | - | tiles = map.getTileSets().getTileSet(tileSet).iterator(); |
9 | + | TiledMapTile tile = tiles.next(); |
10 | - | |
10 | + | if(tile.getProperties().containsKey("animation") && tile.getProperties().get("animation", String.class).equals(tileToAnimate)) |
11 | - | while(tiles.hasNext()){ |
11 | + | frameTiles.add((StaticTiledMapTile) tile); |
12 | - | TiledMapTile tile = tiles.next(); |
12 | + | |
13 | - | if (tile.getProperties().containsKey("animation") && tile.getProperties().get("animation", String.class).equals(tileToAnimate)) |
13 | + | |
14 | - | frameTiles.add((StaticTiledMapTile) tile); |
14 | + | animatedTiles.add(new AnimatedTiledMapTile(delayBetweenAnimation, frameTiles)); |
15 | - | } |
15 | + | for(TiledMapTile tile : frameTiles) |
16 | - | |
16 | + | animatedTiles.peek().getProperties().putAll(tile.getProperties()); |
17 | - | animatedTiles.add(new AnimatedTiledMapTile(delayBetweenAnimation, frameTiles)); |
17 | + | |
18 | - | for(TiledMapTile tile : frameTiles) |
18 | + | for(int x = 0; x < backgroundLayer.getWidth(); x++) |
19 | - | animatedTiles.peek().getProperties().putAll(tile.getProperties()); |
19 | + | for(int y = 0; y < backgroundLayer.getHeight(); y++) { |
20 | - | |
20 | + | Cell cell = backgroundLayer.getCell(x, y); |
21 | - | for(int x = 0; x < backgroundLayer.getWidth(); x++){ |
21 | + | if(cell.getTile().getProperties().containsKey("animation") && cell.getTile().getProperties().get("animation", String.class).equals(tileToAnimate)) |
22 | - | for(int y = 0; y < backgroundLayer.getHeight(); y++){ |
22 | + | cell.setTile(animatedTiles.peek()); |
23 | - | Cell cell = backgroundLayer.getCell(x, y); |
23 | + | |
24 | - | if(cell.getTile().getProperties().containsKey("animation") && cell.getTile().getProperties().get("animation", String.class).equals(tileToAnimate)) |
24 | + | } |