Search in sources :

Example 6 with Collision

use of com.b3dgs.lionengine.game.feature.collidable.Collision in project lionengine by b3dgs.

the class CollidableFramedConfig method exports.

/**
 * Create an XML node from a collision.
 *
 * @param root The node root (must not be <code>null</code>).
 * @param collisions The collisions reference (must not be <code>null</code>).
 */
public static void exports(Xml root, Map<Integer, Collection<Collision>> collisions) {
    Check.notNull(root);
    Check.notNull(collisions);
    for (final Entry<Integer, Collection<Collision>> entry : collisions.entrySet()) {
        for (final Collision collision : entry.getValue()) {
            final Xml node = root.createChild(NODE_COLLISION_FRAMED);
            node.writeInteger(ATT_NUMBER, entry.getKey().intValue());
            node.writeInteger(ATT_OFFSETX, collision.getOffsetX());
            node.writeInteger(ATT_OFFSETY, collision.getOffsetY());
            node.writeInteger(ATT_WIDTH, collision.getWidth());
            node.writeInteger(ATT_HEIGHT, collision.getHeight());
            node.writeBoolean(ATT_MIRROR, collision.hasMirror());
        }
    }
}
Also used : Xml(com.b3dgs.lionengine.Xml) Collision(com.b3dgs.lionengine.game.feature.collidable.Collision) Collection(java.util.Collection)

Aggregations

Collision (com.b3dgs.lionengine.game.feature.collidable.Collision)6 Collection (java.util.Collection)6 Xml (com.b3dgs.lionengine.Xml)5 Configurer (com.b3dgs.lionengine.game.Configurer)4 HashMap (java.util.HashMap)4 Animation (com.b3dgs.lionengine.Animation)3 LionEngineException (com.b3dgs.lionengine.LionEngineException)2 Media (com.b3dgs.lionengine.Media)2 Collections (java.util.Collections)2 Test (org.junit.jupiter.api.Test)2 AnimatorFrameListener (com.b3dgs.lionengine.AnimatorFrameListener)1 Check (com.b3dgs.lionengine.Check)1 Constant (com.b3dgs.lionengine.Constant)1 XmlReader (com.b3dgs.lionengine.XmlReader)1 AnimationConfig (com.b3dgs.lionengine.game.AnimationConfig)1 Animatable (com.b3dgs.lionengine.game.feature.Animatable)1 Featurable (com.b3dgs.lionengine.game.feature.Featurable)1 FeatureGet (com.b3dgs.lionengine.game.feature.FeatureGet)1 FeatureModel (com.b3dgs.lionengine.game.feature.FeatureModel)1 Recyclable (com.b3dgs.lionengine.game.feature.Recyclable)1