本文整理匯總了Java中com.b3dgs.lionengine.game.feature.tile.map.MapTileGame類的典型用法代碼示例。如果您正苦於以下問題:Java MapTileGame類的具體用法?Java MapTileGame怎麽用?Java MapTileGame使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
MapTileGame類屬於com.b3dgs.lionengine.game.feature.tile.map包,在下文中一共展示了MapTileGame類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: generate
import com.b3dgs.lionengine.game.feature.tile.map.MapTileGame; //導入依賴的package包/類
/**
* Generate a map.
*
* @param services The services reference.
* @param theme The theme name.
* @return The generated map.
*/
public static MapTile generate(Services services, String theme)
{
final MapTile map = services.create(MapTileGame.class);
map.addFeature(new LayerableModel(Constant.LAYER_MAP));
map.loadSheets(Medias.create(Constant.FOLDER_TILE, theme, TileSheetsConfig.FILENAME));
final java.util.Map<TileRef, Media> entities = getEntities(theme);
final TileSetListener listener = createListener(entities, map, services);
map.addListener(listener);
final List<MapTile> maps = getMaps(theme, MAX_LEVELS);
final Collection<MapTile> levels = new ArrayList<MapTile>();
for (int i = 0; i < MAX_LEVELS; i++)
{
final MapTile current = maps.get(UtilRandom.getRandomInteger(maps.size() - 1));
levels.add(current);
}
map.append(levels, 0, 1, 0, MAX_LEVEL_INTERVAL_HEIGHT_IN_TILE);
map.removeListener(listener);
entities.clear();
return map;
}
示例2: getMaps
import com.b3dgs.lionengine.game.feature.tile.map.MapTileGame; //導入依賴的package包/類
/**
* Get a list of maps.
*
* @param theme The theme name.
* @param count The file level count.
* @return List of maps.
*/
private static List<MapTile> getMaps(String theme, int count)
{
final List<MapTile> maps = new ArrayList<MapTile>();
for (int i = 0; i <= count; i++)
{
final Media level = Medias.create(Constant.FOLDER_LEVELS, theme, i + ".map");
final Services services = new Services();
final MapTile map = services.create(MapTileGame.class);
final MapTilePersister persister = map.addFeatureAndGet(new MapTilePersisterModel(services));
try
{
final FileReading reading = new FileReading(level);
persister.load(reading);
reading.close();
}
catch (final IOException exception)
{
Verbose.exception(exception);
}
maps.add(map);
}
return maps;
}