//Es como un manager de tiles public void update() { //Si la iteracion no pasa el maximo se repite for (int y = 0; y < MAP_HEIGHT; y++) { //Si la iteracion no pasa el maximo se repite for (int x = 0; x < MAP_WIDTH; x++) { //se update los tiles a medida que cambie mMap[y][x].update(); } } int col = (int)(CMouse.getX() / TILE_WIDTH); int row = (int)(CMouse.getY() / TILE_HEIGHT); CTile tile = getTile(col, row); if (tile != null) { if (CMouse.firstPress()) { int index = tile.getTileIndex(); if (index == 0) { tile.setTileIndex(1); tile.setImage(mTiles[1]); } else if (index == 1) { tile.setTileIndex(0); tile.setImage(mTiles[0]); } } } }
public void changeTile(CTile tile, CTile.Type type, int imageIndex = -1) { tile.setTileType(type); if (imageIndex < 0) { imageIndex = tile.getTileIndex() - 1; } tile.setImage(mTiles[imageIndex]); }
public void update() { for (int y = 0; y < MAP_HEIGHT; y++) { for (int x = 0; x < MAP_WIDTH; x++) { mMap [y] [x].update(); // RUNNER //mMap[y][x].setVelX(-400); } } int col = (int)(CMouse.getX() / TILE_WIDTH); int row = (int)(CMouse.getY() / TILE_HEIGHT); CTile tile = getTile(col, row); if (tile != null) { if (CMouse.firstPress()) { int index = tile.getTileIndex(); if (index == 0) { tile.setTileIndex(1); tile.setImage(mTiles[1]); } else if (index == 1) { tile.setTileIndex(0); tile.setImage(mTiles[0]); } } } }