All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.czyzby.lml.parser.impl.attribute.YLmlAttribute Maven / Gradle / Ivy

package com.github.czyzby.lml.parser.impl.attribute;

import com.badlogic.gdx.scenes.scene2d.Actor;
import com.github.czyzby.lml.parser.LmlParser;
import com.github.czyzby.lml.parser.tag.LmlAttribute;
import com.github.czyzby.lml.parser.tag.LmlTag;
import com.github.czyzby.lml.util.LmlUtilities;

/** Allows to specify initial position of the actor on the stage. Expends a float value (absolute position).
 *
 * 

* Note that it works MOSTLY if the actor is a root - has no parent and is attached to a stage by the parser, not * manually. Most groups will override this setting. If used on a root actor, it can accept float values (absolute * position) or a float ending with a '%' (for example, "0.5%"). If a percent is passed, it will set the Y position as a * percent of stage's initial height. For the most predictable results, set both x and y attributes. * *

* By default, mapped to "y". * * @author MJ * @see XLmlAttribute */ public class YLmlAttribute implements LmlAttribute { @Override public Class getHandledType() { return Actor.class; } @Override public void process(final LmlParser parser, final LmlTag tag, final Actor actor, final String rawAttributeData) { if (tag.getParent() == null) { // Attaching to stage with selected position: LmlUtilities.getLmlUserObject(actor).parseYPosition(parser, actor, rawAttributeData); } else { actor.setY(parser.parseFloat(rawAttributeData, actor)); } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy