Example usage for com.badlogic.gdx.scenes.scene2d Actor setTouchable

List of usage examples for com.badlogic.gdx.scenes.scene2d Actor setTouchable

Introduction

In this page you can find the example usage for com.badlogic.gdx.scenes.scene2d Actor setTouchable.

Prototype

public void setTouchable(Touchable touchable) 

Source Link

Document

Determines how touch events are distributed to this actor.

Usage

From source file:com.bagon.matchteam.mtx.utils.UtilsActor.java

License:Apache License

/**
 * Set touchable for multiple actors at once
 * *//*  www  . j a  v a  2  s  .c  om*/
public static void setTouchable(Touchable touchable, Actor... actors) {
    for (Actor a : actors) {
        a.setTouchable(touchable);
    }
}

From source file:com.ridiculousRPG.ui.ActorFocusUtil.java

License:Apache License

public static void disableRecursive(Array<Actor> actors) {
    if (actors == null)
        return;/*from  w w w .j  av a2  s. c  o m*/
    for (int i = actors.size - 1; i > -1; i--) {
        Actor a = actors.get(i);
        a.setTouchable(Touchable.disabled);
        if (a instanceof Group) {
            disableRecursive(((Group) a).getChildren());
        }
    }
}

From source file:com.vlaaad.dice.ui.windows.LevelUpWindow.java

License:Open Source License

private void addAbilities(Table table, Array<Ability> abilities, boolean isProfession) {
    Table icons = new Table(Config.skin);
    abilities.sort(Ability.COST_COMPARATOR);
    for (Ability ability : abilities) {
        Actor icon;
        if (isProfession) {
            ProfessionAbilityIcon abilityIcon = new ProfessionAbilityIcon(result.creature, ability);
            abilityIcon.drawProgress = false;
            icon = abilityIcon;/*  w  w w.j  a va 2  s.  co m*/
            icon.setTouchable(Touchable.disabled);
        } else {
            Image image = new Image(Config.skin, "ability/" + ability.name + "-icon");
            image.setScaling(Scaling.stretch);
            icon = image;
        }
        icons.add(icon).size(icon.getWidth() * 2, icon.getHeight() * 2).pad(isProfession ? 0 : -8);
    }
    String enumData = Thesaurus.Util.enumerate(Config.thesaurus, abilities,
            new Thesaurus.Util.Stringifier<Ability>() {
                @Override
                public String toString(Ability ability) {
                    return ability.locNameKey() + ".acc";
                }
            });

    LocLabel availableDescription = new LocLabel(
            isProfession ? "ui-level-up-profession-abilities" : "ui-level-up-abilities", Thesaurus.params()
                    .with("enum", enumData).with("grammatical-number", abilities.size > 1 ? "are" : "is"));
    availableDescription.setWrap(true);
    availableDescription.setAlignment(Align.center);
    table.add(icons).row();
    table.add(availableDescription).width(100).padTop(isProfession ? 0 : -4).row();
}

From source file:es.eucm.ead.editor.view.widgets.MultiWidget.java

License:Open Source License

public void addWidget(Actor actor, Color color) {
    actor.setTouchable(Touchable.disabled);

    if (actor instanceof Table) {
        ((Table) actor).setTransform(true);
    }/*from www  . j av a  2  s .c  o m*/
    widgets.add(actor);
    colors.add(color);

    if (getActor() == null) {
        setActor(actor);
        setColor(color == null ? style.color : color);
        toShow = actor;
        actor.setTouchable(Touchable.enabled);
    }
}

From source file:es.eucm.ead.editor.view.widgets.MultiWidget.java

License:Open Source License

public void setSelectedWidget(int index) {
    if (widgets.size > index) {
        Actor newBar = widgets.get(index);

        if (newBar != toShow) {
            Color color = colors.get(index);
            setColor(color == null ? style.color : color);

            for (Actor widget : widgets) {
                widget.clearActions();//from  ww  w. j  a  va2 s.  co  m
            }

            Actor current = getActor();
            if (current != null) {
                current.setTouchable(Touchable.disabled);
            } else {
                current = toShow;
            }

            toShow = newBar;

            Actor toHide = current;
            toHide.setOrigin(Align.center);

            if (toShow.getScaleY() == 1) {
                toShow.setScaleY(0);
                toShow.setOriginY(toHide.getOriginY());
                toShow.getColor().a = 0;
            }

            float timeHide = ANIM_TIME * Math.abs(toHide.getScaleY());

            Action actionShow = Actions.run(actionAddActor);
            Action actionHide = Actions.parallel(Actions.scaleTo(1, 0, timeHide, Interpolation.sineOut),
                    Actions.fadeOut(timeHide));

            if (newBar == current) {
                toHide.addAction(actionShow);
            } else {
                toHide.addAction(Actions.sequence(actionHide, actionShow));
            }
        }
    }
}

From source file:es.eucm.ead.editor.view.widgets.scenes.SceneEditor.java

License:Open Source License

private void setTouchableAndVisible(Actor actor) {
    ModelEntity entity = Q.getModelEntity(actor);
    if (entity != null) {
        ElementEditState elementState = Q.getComponent(entity, ElementEditState.class);
        if (elementState.isLock()) {
            actor.setTouchable(Touchable.disabled);
        } else {/*w  w  w .  j  ava 2  s .  co m*/
            actor.setTouchable(Touchable.enabled);
        }
        actor.setVisible(!elementState.isInvisible());
        if (actor instanceof Group) {
            for (Actor child : ((Group) actor).getChildren()) {
                setTouchableAndVisible(child);
            }
        }
    }

}

From source file:mobi.shad.s3lib.gui.GuiUtil.java

License:Apache License

/**
 * @param source//from w ww.j av  a  2s  .c om
 * @param destination
 */
public static void copyActor(Actor source, Actor destination) {
    destination.setBounds(source.getX(), source.getY(), source.getWidth(), source.getHeight());
    destination.setColor(source.getColor());
    destination.setName(source.getName());
    destination.setOrigin(source.getOriginX(), source.getOriginY());
    destination.setRotation(source.getRotation());
    destination.setScale(source.getScaleX(), source.getScaleY());
    destination.setTouchable(source.getTouchable());
    destination.setUserObject(source.getUserObject());
    destination.setVisible(source.isVisible());
    destination.setZIndex(source.getZIndex());
    destination.getStage();
}

From source file:net.mwplay.cocostudio.ui.BaseWidgetParser.java

License:Apache License

/**
 * common attribute parser/*from w  ww.j a va 2  s  .  c  o  m*/
 * 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());
    }

    // CocoStudioScaleX,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;
}

From source file:net.mwplay.cocostudio.ui.parser.GroupParser.java

License:Apache License

/**
 * ?group,?Group?Widget???/*from  w ww  .j a v  a2  s.  c om*/
 */
public Group groupChildrenParse(CocoStudioUIEditor editor, ObjectData widget, Group parent, Actor actor) {

    Group group = (Group) actor;

    // Group ?,?
    actor.setTouchable(widget.isTouchEnable() ? Touchable.enabled : Touchable.childrenOnly);
    // Transform true ???.

    // group.setTransform(true);

    if (widget.getScale() != null || widget.getRotation() != 0) {
        group.setTransform(true);
    }

    for (ObjectData childrenWidget : widget.getChildren()) {
        Actor childrenActor = editor.parseWidget(group, childrenWidget);
        if (childrenActor == null) {
            continue;
        }
        group.addActor(childrenActor);
    }
    sort(widget, group);

    return group;

}

From source file:net.mwplay.cocostudio.ui.parser.WidgetParser.java

License:Apache License

/**
 * ??/*from   w w w.  j  a  v  a  2s  .c  o m*/
 */
public Group widgetChildrenParse(CocoStudioUIEditor editor, ObjectData widget, Group parent, Actor actor) {
    Table table = new Table();
    table.setClip(widget.isClipAble());
    table.setName(actor.getName());

    Scale scale = widget.getScale();

    if (scale != null) {
        table.setScale(scale.getScaleX(), scale.getScaleY());
    }

    table.setRotation(actor.getRotation());
    table.setVisible(actor.isVisible());

    table.setTouchable(widget.isTouchEnable() ? Touchable.enabled : Touchable.childrenOnly);

    // editor.getActors().get(actor.getName()).removeValue(actor, true);
    //
    // addActor(editor, table, option);

    actor.setVisible(true);
    actor.setTouchable(Touchable.disabled);

    if (scale != null || widget.getRotation() != 0) {
        table.setTransform(true);
    }

    table.setSize(actor.getWidth(), actor.getHeight());
    table.setPosition(actor.getX(), actor.getY());

    // ?

    Scale anchorPoint = widget.getAnchorPoint();
    if (anchorPoint != null) {

        table.setOrigin(anchorPoint.getScaleX() * table.getWidth(),
                anchorPoint.getScaleY() * table.getHeight());
    }
    for (ObjectData childrenWidget : widget.getChildren()) {
        Actor childrenActor = editor.parseWidget(table, childrenWidget);
        if (childrenActor == null) {
            continue;
        }
        table.addActor(childrenActor);
    }
    sort(widget, table);

    // Widget?Table??.Widget?Table
    actor.setPosition(0, 0);
    actor.setScale(1, 1);
    table.addActorAt(0, actor);
    return table;
}