use of com.b3dgs.lionengine.game.SizeConfig 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.game.SizeConfig in project lionengine by b3dgs.
the class ProducibleConfigTest method testExportsImports.
/**
* Test exports imports.
*/
@Test
void testExportsImports() {
final ProducibleConfig producible = new ProducibleConfig(1, 2, 3);
final Xml root = new Xml("test");
root.add(SizeConfig.exports(new SizeConfig(producible.getWidth(), producible.getHeight())));
root.add(ProducibleConfig.exports(producible));
final Media media = Medias.create("producible.xml");
root.save(media);
assertEquals(producible, ProducibleConfig.imports(new Xml(media)));
assertEquals(producible, ProducibleConfig.imports(new Setup(media)));
assertEquals(producible, ProducibleConfig.imports(new Configurer(media)));
assertTrue(media.getFile().delete());
}
use of com.b3dgs.lionengine.game.SizeConfig in project lionengine by b3dgs.
the class UtilTransformable method createMedia.
/**
* Create the object media.
*
* @param caller The caller class.
* @return The object media.
*/
public static Media createMedia(Class<?> caller) {
final Xml root = new Xml("test");
root.add(FeaturableConfig.exportClass(Featurable.class.getName()));
root.add(SizeConfig.exports(new SizeConfig(16, 32)));
final Media media = Medias.create("transformable_" + caller.getSimpleName() + Factory.FILE_DATA_DOT_EXTENSION);
root.save(media);
return media;
}
use of com.b3dgs.lionengine.game.SizeConfig 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(XmlReader root) {
Check.notNull(root);
final XmlReader node = root.getChild(NODE_PRODUCIBLE);
final SizeConfig size = SizeConfig.imports(root);
final int time = node.getInteger(ATT_STEPS);
return new ProducibleConfig(time, size.getWidth(), size.getHeight());
}
use of com.b3dgs.lionengine.game.SizeConfig in project lionengine by b3dgs.
the class UtilProducible method createProducibleMedia.
/**
* Create media.
*
* @return The media.
*/
public static Media createProducibleMedia() {
final ProducibleConfig producibleConfig = new ProducibleConfig(1, 2, 3);
final Media media = UtilSetup.createMedia(Featurable.class);
final Xml root = new Xml("test");
root.add(SizeConfig.exports(new SizeConfig(producibleConfig.getWidth(), producibleConfig.getHeight())));
root.add(ProducibleConfig.exports(producibleConfig));
root.save(media);
return media;
}
Aggregations