use of com.b3dgs.lionengine.io.Xml in project lionengine by b3dgs.
the class FramesConfig method imports.
/**
* Imports the frames config from node.
*
* @param root The root reference (must not be <code>null</code>).
* @return The frames data.
* @throws LionEngineException If unable to read node or invalid integer.
*/
public static FramesConfig imports(Xml root) {
Check.notNull(root);
final Xml node = root.getChild(NODE_FRAMES);
final int horizontals = node.readInteger(ATT_HORIZONTAL);
final int verticals = node.readInteger(ATT_VERTICAL);
final int offsetX = node.readInteger(0, ATT_OFFSET_X);
final int offsetY = node.readInteger(0, ATT_OFFSET_Y);
return new FramesConfig(horizontals, verticals, offsetX, offsetY);
}
use of com.b3dgs.lionengine.io.Xml in project lionengine by b3dgs.
the class SizeConfig method imports.
/**
* Import the size data from configurer.
*
* @param root The root reference (must not be <code>null</code>).
* @return The size data.
* @throws LionEngineException If unable to read node.
*/
public static SizeConfig imports(Xml root) {
Check.notNull(root);
final Xml node = root.getChild(NODE_SIZE);
final int width = node.readInteger(ATT_WIDTH);
final int height = node.readInteger(ATT_HEIGHT);
return new SizeConfig(width, height);
}
use of com.b3dgs.lionengine.io.Xml in project lionengine by b3dgs.
the class ProducibleConfig method imports.
/**
* Create the producible data from node.
*
* @param root The root reference (must not be <code>null</code>).
* @return The producible data.
* @throws LionEngineException If unable to read node.
*/
public static ProducibleConfig imports(Xml root) {
Check.notNull(root);
final Xml node = root.getChild(NODE_PRODUCIBLE);
final SizeConfig size = SizeConfig.imports(root);
final int time = node.readInteger(ATT_STEPS);
return new ProducibleConfig(time, size.getWidth(), size.getHeight());
}
use of com.b3dgs.lionengine.io.Xml in project lionengine by b3dgs.
the class TileConfig method exports.
/**
* Export the tile as a node.
*
* @param tileRef The tile to export (must not be <code>null</code>).
* @return The exported node.
* @throws LionEngineException If <code>null</code> argument or error on writing.
*/
public static Xml exports(TileRef tileRef) {
Check.notNull(tileRef);
final Xml node = new Xml(NODE_TILE);
node.writeInteger(ATT_TILE_SHEET, tileRef.getSheet().intValue());
node.writeInteger(ATT_TILE_NUMBER, tileRef.getNumber());
return node;
}
use of com.b3dgs.lionengine.io.Xml in project lionengine by b3dgs.
the class Raster method load.
/**
* Load raster from media.
*
* @param media The raster media (must not be <code>null</code>).
* @return The raster channels data.
* @throws LionEngineException If <code>null</code> argument or unable to read data.
*/
public static Raster load(Media media) {
Check.notNull(media);
final Xml root = new Xml(media);
final RasterData dataRed = RasterData.load(root, CHANNEL_RED);
final RasterData dataGreen = RasterData.load(root, CHANNEL_GREEN);
final RasterData dataBlue = RasterData.load(root, CHANNEL_BLUE);
return new Raster(dataRed, dataGreen, dataBlue);
}
Aggregations