本文整理汇总了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;
}