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

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

Introduction

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

Prototype

public void setVisible(boolean visible) 

Source Link

Document

If false, the actor will not be drawn and will not receive touch events.

Usage

From source file:com.agateau.ui.UiBuilder.java

License:Apache License

protected void applyActorProperties(Actor actor, XmlReader.Element element, Group parentActor) {
    AnchorGroup anchorGroup = null;/* ww w. j a  v a 2  s .  c o  m*/
    if (parentActor != null) {
        parentActor.addActor(actor);
        if (parentActor instanceof AnchorGroup) {
            anchorGroup = (AnchorGroup) parentActor;
        }
    }
    String attr = element.getAttribute("x", "");
    if (!attr.isEmpty()) {
        actor.setX(Float.parseFloat(attr));
    }
    attr = element.getAttribute("y", "");
    if (!attr.isEmpty()) {
        actor.setY(Float.parseFloat(attr));
    }
    attr = element.getAttribute("width", "");
    if (!attr.isEmpty()) {
        actor.setWidth(Float.parseFloat(attr));
    }
    attr = element.getAttribute("height", "");
    if (!attr.isEmpty()) {
        actor.setHeight(Float.parseFloat(attr));
    }
    attr = element.getAttribute("originX", "");
    if (!attr.isEmpty()) {
        actor.setOriginX(Float.parseFloat(attr));
    }
    attr = element.getAttribute("originY", "");
    if (!attr.isEmpty()) {
        actor.setOriginY(Float.parseFloat(attr));
    }
    attr = element.getAttribute("visible", "");
    if (!attr.isEmpty()) {
        actor.setVisible(Boolean.parseBoolean(attr));
    }
    attr = element.getAttribute("color", "");
    if (!attr.isEmpty()) {
        actor.setColor(Color.valueOf(attr));
    }
    attr = element.getAttribute("debug", "");
    if (!attr.isEmpty()) {
        if (actor instanceof Group) {
            Group group = (Group) actor;
            attr = attr.toLowerCase();
            if (attr.equals("true")) {
                group.debug();
            } else if (attr.equals("all")) {
                group.debugAll();
            }
        } else {
            actor.setDebug(Boolean.parseBoolean(attr));
        }
    }
    for (int idx = 0, size = ANCHOR_NAMES.length; idx < size; ++idx) {
        String anchorName = ANCHOR_NAMES[idx];
        attr = element.getAttribute(anchorName, "");
        if (!attr.isEmpty()) {
            if (anchorGroup == null) {
                throw new RuntimeException("Parent of " + actor + " is not an anchor group");
            }
            PositionRule rule = parseRule(attr, anchorGroup.getSpacing());
            rule.target = actor;
            rule.targetAnchor = ANCHORS[idx];
            anchorGroup.addRule(rule);
        }
    }
}

From source file:com.badlogic.gdx.ai.tests.utils.scene2d.PauseButton.java

private void initialize(final Actor cover) {
    this.addListener(new ChangeListener() {
        @Override/* w  w  w .j a  v  a 2 s .c  o  m*/
        public void changed(ChangeEvent event, Actor actor) {
            boolean pause = isChecked();
            setText(pause ? RESUME_AI : PAUSE_AI);
            if (cover != null)
                cover.setVisible(pause);
        }
    });
}

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

License:Apache License

/**
 * Set visible for multiple actors at once
 * *//*ww w .  j  a v  a  2  s  . c o m*/
public static void setVisible(boolean isVisible, Actor... actors) {
    for (Actor a : actors) {
        a.setVisible(isVisible);
    }
}

From source file:com.quadbits.gdxhelper.controllers.LinearTrajectoryController.java

License:Apache License

protected void enterScene(Actor actor) {
    outOfScene = false;/*www .  jav a2  s  . co  m*/
    currentOutOfSceneTimeMillis = 0;
    actor.setVisible(true);
    currentInterpolationValue = 0;

    boolean reverse = false;
    if (reversable) {
        reverse = random.nextBoolean();
    }

    // choose source and target points
    if (!reverse) {
        chooseRandomSourceAndTarget(sourceX1, sourceY1, sourceX2, sourceY2, targetX1, targetY1, targetX2,
                targetY2);
        if (actor instanceof FlippableActor) {
            ((FlippableActor) actor).setFlipX(false);
        }
    } else {
        chooseRandomSourceAndTarget(targetX1, targetY1, targetX2, targetY2, sourceX1, sourceY1, sourceX2,
                sourceY2);
        if (actor instanceof FlippableActor) {
            ((FlippableActor) actor).setFlipX(true);
        }
    }

    // calculate interpolation step
    tmpVector.set(currentTarget);
    tmpVector.sub(currentSource);
    float speed = avgSpeedMillis + ((float) random.nextGaussian()) * stdSpeedMillis;
    interpolationStep = speed / tmpVector.len();

    // rotate actor (if requested)
    if (adjustActorRotation) {
        float angle = tmpVector.angle();
        if (angle > 90 && angle <= 180) {
            angle = -(180 - angle);
        }
        if (angle > 180 && angle <= 270) {
            angle = angle - 180;
        }
        actor.setRotation(angle);
    }
}

From source file:com.quadbits.gdxhelper.controllers.LinearTrajectoryController.java

License:Apache License

protected void exitScene(Actor actor) {
    outOfScene = true;//from ww w.  j  a v a2 s. c o m
    outOfSceneTimeMillis = avgOutOfSceneTimeMillis + (long) (random.nextGaussian() * stdOutOfSceneTimeMillis);
    currentOutOfSceneTimeMillis = 0;
    actor.setVisible(false);
}

From source file:com.quadbits.gdxhelper.controllers.OnlyAtNightController.java

License:Apache License

@Override
public void control(Actor actor, float deltaSeconds) {
    float alpha;/*from www. java2s  . com*/
    switch (timeManager.getPeriod()) {
    case PRE_MIDNIGHT:
    case POST_MIDNIGHT:
        alpha = 1;
        break;

    case TWILIGHT_POST_SUNSET:
        alpha = timeManager.getTPeriod();
        break;

    case TWILIGHT_PRE_SUNRISE:
        alpha = 1 - timeManager.getTPeriod();
        break;

    default:
        alpha = 0;
    }

    actor.getColor().a = alpha;

    if (alpha <= 0) {
        actor.setVisible(false);
    } else {
        actor.setVisible(true);
    }
}

From source file:com.quadbits.gdxhelper.controllers.OnlyAtNightPeriodController.java

License:Apache License

@Override
public void control(Actor actor, float deltaSeconds) {
    float alpha;/*from w  ww .  j  a va 2 s  .c om*/
    float tNight = timeManager.getTNight();

    if (tNight < tBegin) {
        alpha = 0;
    } else if (tNight > tBegin && tNight < tBegin + tTransition) {
        alpha = (tNight - tBegin) / tTransition;
    } else if (tNight < tEnd - tTransition) {
        alpha = 1;
    } else if (tNight < tEnd) {
        alpha = (tEnd - tNight) / tTransition;
    } else {
        alpha = 0;
    }

    actor.getColor().a = alpha;

    if (alpha <= 0) {
        actor.setVisible(false);
    } else {
        actor.setVisible(true);
    }
}

From source file:com.quadbits.gdxhelper.controllers.ParabolaController.java

License:Apache License

@Override
public void control(Actor actor, float deltaSeconds) {
    float t = getT();

    // Check t bounds
    if (t < 0 || t > 1) {
        if (outOfBoundsPolicy == OutOfBoundsPolicy.HIDE) {
            actor.setVisible(false);
        }//from   w w  w  . j a  v a2  s.  co  m
        return;
    }

    // Calculate the actor's position using the parabola equation
    actor.setVisible(true);
    parabolaEq.getPosition(t, tmpVec);
    actor.setPosition(tmpVec.x, tmpVec.y);
}

From source file:com.quadbits.gdxhelper.controllers.TimePeriodVisibilityController.java

License:Apache License

@Override
public void control(Actor actor, float deltaSeconds) {
    if (timeManager == null || membershipFunction == null) {
        return;// ww w  . j a v a2s. com
    }

    float alpha = membershipFunction.evaluate(timeManager);
    actor.getColor().a = alpha;

    if (alpha <= 0) {
        actor.setVisible(false);
    } else {
        actor.setVisible(true);
    }
}

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

License:Open Source License

@Override
public void setVisible(boolean visible) {
    super.setVisible(visible);
    if (!visible) {
        for (Actor a : getChildren()) {
            if (!(a instanceof Separator)) {
                a.setVisible(false);
            }/*from w w w .jav a2 s.c o  m*/
        }
    }
}