Java Code Examples for com.badlogic.gdx.scenes.scene2d.Actor#setColor()

The following examples show how to use com.badlogic.gdx.scenes.scene2d.Actor#setColor() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AdvancedColorLmlAttribute.java    From gdx-vfx with Apache License 2.0 6 votes vote down vote up
@Override
public void process(final LmlParser parser, final LmlTag tag, final Actor actor, final String rawAttributeData) {
    if (rawAttributeData.startsWith("#")) {
        String hexCode = rawAttributeData.substring(1);
        Color color;
        try {
            color = CommonUtils.parseHexColor(hexCode);
        } catch (Exception e) {
            parser.throwError("Error parsing HEX code value \"" + hexCode + "\"", e);
            return;
        }
        actor.setColor(color);
    } else {
        super.process(parser, tag, actor, rawAttributeData);
    }
}
 
Example 2
Source File: Scene2dUtils.java    From gdx-vfx with Apache License 2.0 5 votes vote down vote up
public static void setColorRecursively(Actor actor, Color color) {
    if (actor instanceof Group) {
        Group group = (Group) actor;
        for (Actor child : group.getChildren()) {
            setColorRecursively(child, color);
        }
    }
    actor.setColor(color);
}
 
Example 3
Source File: HexColorLmlAttribute.java    From gdx-texture-packer-gui with Apache License 2.0 5 votes vote down vote up
@Override
public void process(final LmlParser parser, final LmlTag tag, final Actor actor, final String rawAttributeData) {
    String hexValue = parser.parseString(rawAttributeData, actor);
    try {
        Color color = Color.valueOf(hexValue);
        actor.setColor(color);
    } catch (Exception exception) {
        parser.throwErrorIfStrict(
                "Unable to parse HEX color value from string \"" + hexValue + "\"",
                exception);
    }
}
 
Example 4
Source File: BaseWidgetParser.java    From cocos-ui-libgdx with Apache License 2.0 4 votes vote down vote up
/**
 * common attribute parser
 * according cocstudio ui setting properties of the configuration file
 *
 * @param editor
 * @param widget
 * @param parent
 * @param actor
 * @return
 */
public Actor commonParse(CocoStudioUIEditor editor, ObjectData widget,
                         Group parent, Actor actor) {
    this.editor = editor;
    actor.setName(widget.getName());
    actor.setSize(widget.getSize().getX(), widget.getSize().getY());
    // set origin
    if (widget.getAnchorPoint() != null) {
        actor.setOrigin(widget.getAnchorPoint().getScaleX() * actor.getWidth(),
            widget.getAnchorPoint().getScaleY() * actor.getHeight());
    }

    //判空,因为新版本的单独节点没有Postion属性
    if (widget.getPosition() != null) {
        actor.setPosition(widget.getPosition().getX() - actor.getOriginX(),
            widget.getPosition().getY() - actor.getOriginY());
    }

    // CocoStudio的编辑器ScaleX,ScaleY 会有负数情况
    //判空,因为新版本的单独节点没有Scale属性
    if (widget.getScale() != null) {
        actor.setScale(widget.getScale().getScaleX(), widget.getScale()
            .getScaleY());
    }

    if (widget.getRotation() != 0) {// CocoStudio 是顺时针方向旋转,转换下.
        actor.setRotation(360 - widget.getRotation() % 360);
    }
    //添加倾斜角
    if (widget.getRotationSkewX() != 0 && widget.getRotationSkewX() == widget.getRotationSkewY()) {
        actor.setRotation(360 - widget.getRotationSkewX() % 360);
    }

    // 设置可见
    actor.setVisible(widget.isVisibleForFrame());

    Color color = editor.getColor(widget.getCColor(), widget.getAlpha());

    actor.setColor(color);

    actor.setTouchable(deduceTouchable(actor, widget));

    // callback

    addCallback(actor, widget);
    // callback

    addActor(editor, actor, widget);

    if (widget.getChildren() == null || widget.getChildren().size() == 0) {
        //添加Action
        parseAction(actor, widget);

        return actor;
    }

    return null;
}