Java Code Examples for com.badlogic.gdx.scenes.scene2d.ui.Image#getColor()

The following examples show how to use com.badlogic.gdx.scenes.scene2d.ui.Image#getColor() . 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: ViewController.java    From dice-heroes with GNU General Public License v3.0 5 votes vote down vote up
private void addBackgroundObject(boolean anywhere) {
    final Image image = new Image(backgroundDrawables.random());
    backgroundLayer.addActor(image);


    float scale = 0.5f * MathUtils.random(1, 2);
    image.setSize(image.getPrefWidth() * scale, image.getPrefHeight() * scale);
    image.setRotation(MathUtils.random(0, 1) * 180);
    image.getColor().a = MathUtils.random(0.1f, 0.3f);

    float w = Math.max(world.stage.getWidth(), root.getWidth() + ViewScroller.LEFT + ViewScroller.RIGHT);
    float h = Math.max(world.stage.getHeight(), root.getHeight() + ViewScroller.TOP + ViewScroller.BOTTOM);

    if (anywhere)
        image.setPosition(-root.getX() + w * MathUtils.random(), -root.getY() + h * MathUtils.random());
    else
        image.setPosition(-root.getX() - image.getWidth(), -root.getY() + h * MathUtils.random());

    image.addAction(Actions.sequence(
        Actions.moveBy(w + image.getWidth() - image.getX(), 0, 15 + MathUtils.random(6)),
        Actions.run(new Runnable() {
            @Override public void run() {
                image.remove();
                addBackgroundObject(false);
            }
        })
    ));
}
 
Example 2
Source File: DieNet.java    From dice-heroes with GNU General Public License v3.0 5 votes vote down vote up
private void highlight(IntArray indices) {
    for (int i = 0; i < indices.size; i++) {
        Vector2 pos = iconPositions[indices.get(i)];
        Image image = new Image(Config.skin, "ui/dice-window/net-selection-selected");
        image.setPosition(pos.x - 2, pos.y - 2);
        addActor(image);
        image.toBack();
        image.getColor().a = 0f;
        blink(image);
        highlights.add(image);
    }
}
 
Example 3
Source File: IntroState.java    From dice-heroes with GNU General Public License v3.0 4 votes vote down vote up
@Override protected void init() {
    stage.getViewport().update(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    textureImage = new Texture("logo-image.png");
    textureText = new Texture("logo-text.png");

    final Image image = new Image(textureImage);
    image.setPosition(stage.getWidth() / 2 - image.getWidth() / 2, stage.getHeight() / 2 - image.getHeight() / 2);

    final Image text = new Image(textureText);
    text.setPosition(image.getX(), image.getY());

    stage.addActor(image);
    stage.addActor(text);
    image.getColor().a = 0;
    text.getColor().a = 0;

    image.addAction(Actions.sequence(
        Actions.alpha(1, 0.3f),
        Actions.run(new Runnable() {
            @Override public void run() {
                text.addAction(
                    Actions.sequence(
                        Actions.alpha(1, 0.3f),
                        Actions.delay(1.5f),
                        Actions.run(new Runnable() {
                            @Override public void run() {
                                image.addAction(Actions.alpha(0, 0.3f));
                                text.addAction(Actions.sequence(
                                    Actions.alpha(0, 0.3f),
                                    Actions.run(new Runnable() {
                                        @Override public void run() {
                                            callback.onEnded();
                                        }
                                    })
                                ));
                            }
                        })
                    )
                );
            }
        })
    ));
}
 
Example 4
Source File: SplashScreen.java    From Codelabs with MIT License 4 votes vote down vote up
@Override
public void show() {
	stage = new Stage();

	/* Load splash image */
	codelabsImage = new Image(new Texture(
			Gdx.files.internal("data/images/codelabs_splash.png")));
	
	githubImage = new Image(new Texture(
			Gdx.files.internal("data/images/github_splash.png")));

	/* Set the splash image in the center of the screen */
	float width = Gdx.graphics.getWidth();
	float height = Gdx.graphics.getHeight();

	codelabsImage.setPosition((width - codelabsImage.getWidth()) / 2,
			(height - codelabsImage.getHeight()) / 2);

	/* Fade in the image and then swing it down */
	codelabsImage.getColor().a = 0f;
	codelabsImage.addAction(Actions.sequence(Actions.fadeIn(0.5f), Actions
			.delay(1, Actions.fadeOut(0.5f))));
	
	githubImage.setPosition((width - githubImage.getWidth()) / 2,
			(height - githubImage.getHeight()) / 2);

	/* Fade in the image and then swing it down */
	githubImage.getColor().a = 0f;
	githubImage.addAction(Actions.delay(2, Actions.sequence(Actions.fadeIn(0.5f), Actions
			.delay(1, Actions.moveBy(0,
					-(height - githubImage.getHeight() / 2), 1,
					Interpolation.swingIn)), Actions.run(new Runnable() {
		@Override
		public void run() {

			/* Show main menu after swing out */
			((Game) Gdx.app.getApplicationListener())
					.setScreen(new MainMenu());
		}
	}))));

	stage.addActor(codelabsImage);
	stage.addActor(githubImage);
}