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

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

Introduction

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

Prototype

public float getRight() 

Source Link

Document

Returns x plus width.

Usage

From source file:com.kasetagen.game.bubblerunner.screen.BubbleRunnerMenu.java

License:Creative Commons License

private void assembleMenuGroup(TextureAtlas atlas) {

    infiniteLeftDecorator = new ActorDecorator() {
        @Override// ww w  .jav a  2  s . c  o m
        public void applyAdjustment(Actor actor, float v) {
            if (actor.getRight() <= 0f) {
                actor.setPosition(actor.getX() + (actor.getWidth() * 2f), 0f);
            }
        }
    };

    checkedMenuOptionDecorator = new PulsingScaleDecorator(0.025f, 1f);

    float w = stage.getWidth();
    float h = stage.getHeight();
    //Add BG
    bgGroup.addActor(new GenericActor(0f, 0f, w, h, atlas.findRegion(AtlasUtil.ANI_TITLE_BG), Color.BLACK));

    GenericActor moon = new GenericActor(600f, 500f, MOON_WIDTH, MOON_HEIGHT,
            atlas.findRegion(AtlasUtil.ANI_TITLE_MOON), Color.YELLOW);
    moon.addDecorator(new ShakeDecorator(5f, 5f, 4f));
    moon.addDecorator(new OscillatingDecorator(5f, 10f, 2.5f));
    bgGroup.addActor(moon);
    //add Clouds5 setup
    addClouds(atlas.findRegion(AtlasUtil.ANI_TITLE_C5), -25f);

    //Add Skyline2
    bgGroup.addActor(
            new GenericActor(0f, 0f, w, h, atlas.findRegion(AtlasUtil.ANI_TITLE_SKYLINE2), Color.BLACK));

    //Add Cloud 4
    addClouds(atlas.findRegion(AtlasUtil.ANI_TITLE_C4), -25f);

    //Add Cloud 3
    addClouds(atlas.findRegion(AtlasUtil.ANI_TITLE_C3), -75f);

    //Add Skyline1
    bgGroup.addActor(
            new GenericActor(0f, 0f, w, h, atlas.findRegion(AtlasUtil.ANI_TITLE_SKYLINE1), Color.BLACK));

    //Add Title
    bgGroup.addActor(new GenericActor(150f, 25f, TITLE_WIDTH, TITLE_HEIGHT,
            atlas.findRegion(AtlasUtil.ANI_TITLE_TITLE), Color.WHITE));

    //Add Cloud 2
    addClouds(atlas.findRegion(AtlasUtil.ANI_TITLE_C2), -100);

    //Add Cloud 1
    addClouds(atlas.findRegion(AtlasUtil.ANI_TITLE_C1), -125f);

    //Add Platform
    menuGroup.addActor(
            new GenericActor(0f, 0f, w, h, atlas.findRegion(AtlasUtil.ANI_TITLE_PLATFORM), Color.BLACK));

    //Add Edison
    Animation eddyAni = new Animation(EDISON_CYCLE_RATE, atlas.findRegions(AtlasUtil.ANI_TITLE_EDISON));
    menuGroup.addActor(new AnimatedActor(0f, 0f, EDISON_WIDTH, EDISON_HEIGHT, eddyAni, 0f));
    //Add Edyn
    Animation edynAni = new Animation(EDYN_CYCLE_RATE, atlas.findRegions(AtlasUtil.ANI_TITLE_EDYN));
    menuGroup.addActor(new AnimatedActor(w - EDYN_WIDTH, 0f, EDYN_WIDTH, EDYN_HEIGHT, edynAni, 0f));

    Animation edynEyes = new Animation(EYE_CYCLE_RATE, atlas.findRegions(AtlasUtil.ANI_TITLE_EDYN_EYES));
    AnimatedActor eyes = new AnimatedActor(w - EDYN_WIDTH, 0f, EDYN_WIDTH, EDYN_HEIGHT, edynEyes, 0f);
    eyes.setIsLooping(false);
    eyes.addDecorator(new ActorDecorator() {
        private float secondsBeforeBlink = 0f;
        private float elapsedSeconds = 0f;
        private Random rand = new Random(System.currentTimeMillis());

        @Override
        public void applyAdjustment(Actor actor, float v) {
            AnimatedActor a = ((AnimatedActor) actor);

            if (a.isAnimationComplete()) {
                elapsedSeconds += v;
                if (elapsedSeconds >= secondsBeforeBlink) {
                    a.setState(AnimatedActor.DEFAULT_STATE, true);
                    elapsedSeconds = 0f;
                    secondsBeforeBlink = rand.nextInt(MAX_BLINK_INTERVAL) + MIN_BLINK_INTERVAL;
                }
            }
        }
    });

    menuGroup.addActor(eyes);

    Array<TextureAtlas.AtlasRegion> escapeImgs = atlas.findRegions(AtlasUtil.ANI_TITLE_PLAY_BTN);
    TextureRegionDrawable escapeUp = new TextureRegionDrawable(escapeImgs.get(0));
    TextureRegionDrawable escapeDown = new TextureRegionDrawable(escapeImgs.get(1));

    startGameButton = new ImageButton(escapeUp, escapeDown, escapeDown);
    startGameButton.setSize(PLAY_BTN_WIDTH, PLAY_BTN_HEIGHT);
    startGameButton.addListener(listener);
    //startGameButton.setPosition(buttonX, buttonY);
    startGameButton.setChecked(true);

    startUiContainer = new DecoratedUIContainer(startGameButton);
    startUiContainer.setSize(PLAY_BTN_WIDTH, PLAY_BTN_HEIGHT);
    startUiContainer.setPosition(buttonX, buttonY);
    startUiContainer.addDecorator(checkedMenuOptionDecorator);
    menuGroup.addActor(startUiContainer);

    Array<TextureAtlas.AtlasRegion> optionsImgs = atlas.findRegions(AtlasUtil.ANI_TITLE_OPT_BTN);
    TextureRegionDrawable optionsUp = new TextureRegionDrawable(optionsImgs.get(0));
    TextureRegionDrawable optionsDown = new TextureRegionDrawable(optionsImgs.get(1));
    optionsButton = new ImageButton(optionsUp, optionsDown, optionsDown);
    optionsButton.setSize(OPTS_BTN_WIDTH, OPTS_BTN_HEIGHT);

    //optionsButton.setPosition(buttonX, buttonY - (optionsButton.getHeight()));
    optionsButton.addListener(listener);
    optionsUiContainer = new DecoratedUIContainer(optionsButton);
    optionsUiContainer.setPosition(buttonX, buttonY - (PLAY_BTN_HEIGHT));
    optionsUiContainer.setSize(OPTS_BTN_WIDTH, OPTS_BTN_HEIGHT);
    //optUiContainer.addDecorator(checkedMenuOptionDecorator);
    menuGroup.addActor(optionsUiContainer);

    Array<TextureAtlas.AtlasRegion> hsImgs = atlas.findRegions(AtlasUtil.ANI_TITLE_HIGHSCORE_BTN);
    TextureRegionDrawable hsUp = new TextureRegionDrawable(hsImgs.get(0));
    TextureRegionDrawable hsDown = new TextureRegionDrawable(hsImgs.get(1));

    highScoreButton = new ImageButton(hsUp, hsDown, hsDown);
    highScoreButton.setSize(HS_BTN_WIDTH, HS_BTN_HEIGHT);
    highScoreButton.addListener(listener);

    highScoreUiContainer = new DecoratedUIContainer(highScoreButton);
    highScoreUiContainer.setSize(HS_BTN_WIDTH, HS_BTN_HEIGHT);
    highScoreUiContainer.setPosition(buttonX, optionsUiContainer.getY() - (PLAY_BTN_HEIGHT));
    menuGroup.addActor(highScoreUiContainer);
}

From source file:com.kotcrab.vis.ui.util.ActorUtils.java

License:Apache License

/**
 * Makes sures that actor will be fully visible in stage. If it's necessary actor position will be changed to fit it
 * on screen./*from   www.  j  a  v a  2 s. co m*/
 */
public static void keepWithinStage(Stage stage, Actor actor) {
    //taken from scene2d.ui Window
    Camera camera = stage.getCamera();
    if (camera instanceof OrthographicCamera) {
        OrthographicCamera orthographicCamera = (OrthographicCamera) camera;
        float parentWidth = stage.getWidth();
        float parentHeight = stage.getHeight();
        if (actor.getX(Align.right) - camera.position.x > parentWidth / 2 / orthographicCamera.zoom)
            actor.setPosition(camera.position.x + parentWidth / 2 / orthographicCamera.zoom,
                    actor.getY(Align.right), Align.right);
        if (actor.getX(Align.left) - camera.position.x < -parentWidth / 2 / orthographicCamera.zoom)
            actor.setPosition(camera.position.x - parentWidth / 2 / orthographicCamera.zoom,
                    actor.getY(Align.left), Align.left);
        if (actor.getY(Align.top) - camera.position.y > parentHeight / 2 / orthographicCamera.zoom)
            actor.setPosition(actor.getX(Align.top),
                    camera.position.y + parentHeight / 2 / orthographicCamera.zoom, Align.top);
        if (actor.getY(Align.bottom) - camera.position.y < -parentHeight / 2 / orthographicCamera.zoom)
            actor.setPosition(actor.getX(Align.bottom),
                    camera.position.y - parentHeight / 2 / orthographicCamera.zoom, Align.bottom);
    } else if (actor.getParent() == stage.getRoot()) {
        float parentWidth = stage.getWidth();
        float parentHeight = stage.getHeight();
        if (actor.getX() < 0)
            actor.setX(0);
        if (actor.getRight() > parentWidth)
            actor.setX(parentWidth - actor.getWidth());
        if (actor.getY() < 0)
            actor.setY(0);
        if (actor.getTop() > parentHeight)
            actor.setY(parentHeight - actor.getHeight());
    }
}

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

License:Open Source License

private boolean isVisible(Actor actor, float cx, float cy) {
    return (cx > actor.getX() && cx <= actor.getRight() && cy > actor.getY() && cy <= actor.getTop());
}

From source file:net.mwplay.cocostudio.ui.parser.group.CCScrollView.java

License:Apache License

@Override
public Group groupChildrenParse(CocoStudioUIEditor editor, ObjectData widget, Group parent, Actor actor) {
    ScrollPane scrollPane = (ScrollPane) actor;
    Table table = new Table();
    for (ObjectData childrenWidget : widget.getChildren()) {
        Actor childrenActor = editor.parseWidget(table, childrenWidget);
        if (childrenActor == null) {
            continue;
        }//  w w  w .j a v  a2s  . c om

        table.setSize(Math.max(table.getWidth(), childrenActor.getRight()),
                Math.max(table.getHeight(), childrenActor.getTop()));
        table.addActor(childrenActor);
    }
    sort(widget, table);
    //

    scrollPane.setWidget(table);

    return scrollPane;
}

From source file:net.mwplay.cocostudio.ui.widget.TImage.java

License:Apache License

public TImage toRightOf(Actor actor) {
    setPosition(actor.getRight(), actor.getY());
    return this;
}