List of usage examples for com.badlogic.gdx.scenes.scene2d Actor setColor
public void setColor(Color color)
From source file:com.agateau.ui.UiBuilder.java
License:Apache License
protected void applyActorProperties(Actor actor, XmlReader.Element element, Group parentActor) { AnchorGroup anchorGroup = null;/*from w w w . j a va 2 s . c om*/ 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.quadbits.gdxhelper.controllers.TimePeriodTintController.java
License:Apache License
@Override public void control(Actor actor, float deltaSeconds) { if (crossFading) { float deltaColorCrossBlend = deltaSeconds / fadeAnimDurationSeconds; colorCrossBlend += (targetColorCrossBlend == 1) ? deltaColorCrossBlend : -deltaColorCrossBlend; if (colorCrossBlend <= 0) { colorCrossBlend = 0;/* w w w . jav a2 s . c o m*/ crossFading = false; } if (colorCrossBlend >= 1) { colorCrossBlend = 1; crossFading = false; } } float blend = membershipFunction.evaluate(timeManager); //if (blend == 0) { // return; //} tmpColor.set(colors.get(primaryColorIndex)); if (colorCrossBlend != 0 && secondaryColorIndex >= 0) { tmpColor.lerp(colors.get(secondaryColorIndex), colorCrossBlend); } Color actorColor = actor.getColor(); actorColor.set(1, 1, 1, actorColor.a); actorColor.lerp(tmpColor, blend); actor.setColor(actorColor); }
From source file:com.quadbits.gdxhelper.controllers.TintAtNightController.java
License:Apache License
@Override public void control(Actor actor, float deltaSeconds) { float blend;//from w ww .j a v a 2 s . com switch (timeManager.getPeriod()) { case PRE_MIDNIGHT: case POST_MIDNIGHT: blend = 1; break; case TWILIGHT_POST_SUNSET: blend = timeManager.getTPeriod(); break; case TWILIGHT_PRE_SUNRISE: blend = 1 - timeManager.getTPeriod(); break; default: blend = 0; } Color actorColor = actor.getColor(); actorColor.set(1, 1, 1, actorColor.a); actorColor.lerp(nightColor, blend); actor.setColor(actorColor); }
From source file:es.eucm.ead.editor.view.widgets.galleries.ProjectSoundsGallery.java
License:Open Source License
public Gallery.Cell addTile(String path, String title) { Tile tile = WidgetBuilder.tile(title, drawable); Actor background = tile.getBackground(); background.setColor(Color.TEAL); ((Image) background).setScaling(Scaling.none); prepareGalleryItem(tile, null);//from w ww . j a v a 2 s . c o m Gallery.Cell cell = gallery.add(tile); cell.setName(path); return cell; }
From source file:headmade.arttag.screens.IntroScreen.java
License:Apache License
public IntroScreen(final DirectedGame game) { super(game);//from w ww . j av a 2 s. com rootTable = new Table(); rootTable.setFillParent(true); final Actor logo = new Image(Assets.assetsManager.get(Assets.HEADMADE_LOGO, Texture.class)); // logo.setOrigin(logo.getWidth() / 2, logo.getHeight() / 2); // logo.scaleBy(2f); logo.setColor(Color.BLACK); rootTable.add(logo).center().expand(); rootTable.row(); // rootTable.setDebug(true); this.stage.addActor(rootTable); stage.addListener(new InputListener() { @Override public boolean keyDown(InputEvent event, int keycode) { if (keycode == Keys.ESCAPE) { Gdx.app.exit(); return true; } return super.keyDown(event, keycode); } }); Assets.instance.loadAll(); }
From source file:mobi.shad.s3lib.gfx.g2d.EffectCreator.java
License:Apache License
/** * @param actor// w ww . j a va 2 s. c o m * @param effectType * @param value * @param duration * @param type */ public static void createEffect(Actor actor, ScreenEffectType effectType, float value, float duration, InterpolationType type) { if (actor == null) { return; } Interpolation interp = InterpolationType.getInterpolation(type); float x = 0;//actor.getX(); float y = 0;//actor.getY(); switch (effectType) { case SlideLeft: actor.setPosition(999, y); actor.addAction(Actions.moveTo(x, y, duration, interp)); break; case SlideRight: actor.setPosition(-999, y); actor.addAction(Actions.moveTo(x, y, duration, interp)); break; case SlideUp: actor.setPosition(x, -999); actor.addAction(Actions.moveTo(x, y, duration, interp)); break; case SlideDown: actor.setPosition(x, 999); actor.addAction(Actions.moveTo(x, y, duration, interp)); break; case FadeIn: Color color = actor.getColor(); color.a = 0f; actor.setColor(color); actor.addAction(Actions.fadeIn(duration, interp)); break; case FadeOut: Color color2 = actor.getColor(); color2.a = 1f; actor.setColor(color2); actor.addAction(Actions.fadeOut(duration, interp)); break; case FadeInOut: actor.addAction(fadeInOut(value, duration, interp)); break; case ScaleIn: actor.setScale(0, 0); actor.addAction(Actions.scaleTo(1, 1, duration, interp)); break; case ScaleOut: actor.setScale(1, 1); actor.addAction(Actions.scaleTo(0, 0, duration, interp)); break; case None: break; default: break; } }
From source file:mobi.shad.s3lib.gui.GuiUtil.java
License:Apache License
/** * @param source/* w w w . j a va 2 s. 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 w w.j av a2 s .c om*/ * 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:org.ams.testapps.paintandphysics.cardhouse.CardHouseGameMenu.java
License:Open Source License
@Override public void create() { if (debug)//from ww w. j a v a2 s .c o m debug("Creating independent application."); Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA); // ui stuff ScreenViewport sv = new ScreenViewport(); float ui_scale = getUIScale(); sv.setUnitsPerPixel(1f / ui_scale); // extended class to set colors of buttons this.stage = new Stage(sv) { SceneUtil.TraverseTask traverseTask = new SceneUtil.TraverseTask() { @Override public boolean run(Actor actor) { if (actor instanceof TextButton) actor.setColor(cardHouseDef.buttonColor); return true; // continue traversing } }; @Override public void addActor(Actor actor) { super.addActor(actor); traverseChildren(actor, traverseTask); } }; skin = new Skin(Gdx.files.internal("ui/custom/custom.json")); // input inputMultiplexer = new InputMultiplexer(); Gdx.input.setInputProcessor(inputMultiplexer); inputMultiplexer.addProcessor(stage); // background background = new Background(); background.setColor(cardHouseDef.backgroundColor); background.setMatchingBackground(cardHouseDef.backgroundTexture); tips = new Tips("CardHouseGameMenu", stage, skin); preferences = Gdx.app.getPreferences("CardHouseGameMenu"); showMainMenu(); }