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

The following examples show how to use com.badlogic.gdx.scenes.scene2d.ui.Image#setRotation() . 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: RotateODImagesSubView.java    From dice-heroes with GNU General Public License v3.0 5 votes vote down vote up
private void updateImage() {
    Image toUse;
    Image toRemove;
    if (currentIndex % 2 == 0) { // even
        toUse = dia;
        toRemove = orto;
    } else {
        toUse = orto;
        toRemove = dia;
    }
    toRemove.remove();
    group.addActor(toUse);
    toUse.setRotation(getRotation(currentIndex));
}
 
Example 2
Source File: CommonShotVisualizer.java    From dice-heroes with GNU General Public License v3.0 5 votes vote down vote up
@Override public IFuture<Void> visualize(final T result) {
    final Future<Void> future = Future.make();
    final WorldObjectView actorView = visualizer.viewController.getView(result.getActor());
    WorldObjectView targetView = visualizer.viewController.getView(result.getTarget());
    visualizer.viewController.world.dispatcher.dispatch(ResultVisualizer.VISUALIZE_ATTACK, result.getActor());
    Vector2 direction = tmp
        .set(result.getTarget().getX(), result.getTarget().getY())
        .sub(result.getActor().getX(), result.getActor().getY());

    float dx = targetView.getX() - actorView.getX();
    float dy = targetView.getY() - actorView.getY();
    visualizer.viewController.scroller.centerOn(result.getTarget());

    final Image arrow = new Image(Config.skin,"animation/" + result.getAbility().name + "-shot");
    arrow.setPosition(actorView.getX(), actorView.getY());
    visualizer.viewController.effectLayer.addActor(arrow);
    arrow.setOrigin(13, 14);
    arrow.setRotation(direction.angle() - 45);
    arrow.addAction(Actions.sequence(
        Actions.moveBy(dx, dy, tmp.set(dx, dy).len() * 0.002f),
        Actions.run(new Runnable() {
            @Override public void run() {
                SoundManager.instance.playSoundIfExists(result.getAbility().soundName);
                arrow.remove();
                future.happen();
            }
        })
    ));
    return future;
}
 
Example 3
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 4
Source File: ViewController.java    From dice-heroes with GNU General Public License v3.0 5 votes vote down vote up
public static Image addTopRightCornerTransition(String name, int x, int y, Group layer) {
    TextureAtlas.AtlasRegion region = Config.findRegions("transitions/" + name + "-corner").random();
    if (region == null)
        return null;
    Image image = new Image(region);
    layer.addActor(image);
    image.setRotation(-90);
    image.setPosition(x * CELL_SIZE, (y + 1) * CELL_SIZE);
    return image;
}
 
Example 5
Source File: ViewController.java    From dice-heroes with GNU General Public License v3.0 5 votes vote down vote up
public static Image addBottomLeftCornerTransition(String name, int x, int y, Group layer) {
    TextureAtlas.AtlasRegion region = Config.findRegions("transitions/" + name + "-corner").random();
    if (region == null)
        return null;
    Image image = new Image(region);
    layer.addActor(image);
    image.setRotation(90);
    image.setPosition((x + 1) * CELL_SIZE, (y) * CELL_SIZE);
    return image;
}
 
Example 6
Source File: ViewController.java    From dice-heroes with GNU General Public License v3.0 5 votes vote down vote up
public static Image addBottomRightCornerTransition(String name, int x, int y, Group layer) {
    TextureAtlas.AtlasRegion region = Config.findRegions("transitions/" + name + "-corner").random();
    if (region == null)
        return null;
    Image image = new Image(region);
    layer.addActor(image);
    image.setRotation(180);
    image.setPosition((x + 1) * CELL_SIZE, (y + 1) * CELL_SIZE);
    return image;
}
 
Example 7
Source File: ViewController.java    From dice-heroes with GNU General Public License v3.0 5 votes vote down vote up
public static Image addLeftOutline(int x, int y, String name, Group layer) {
    TextureAtlas.AtlasRegion region = Config.findRegions("tile/" + name + "-outline").random();
    if (region == null)
        return null;
    Image image = new Image(region);
    image.setRotation(180);
    layer.addActor(image);
    image.setPosition(x * CELL_SIZE + image.getWidth(), (y + 1) * CELL_SIZE);
    return image;
}
 
Example 8
Source File: ViewController.java    From dice-heroes with GNU General Public License v3.0 5 votes vote down vote up
public static Image addBottomOutline(int x, int y, String name, Group layer) {
    TextureAtlas.AtlasRegion region = Config.findRegions("tile/" + name + "-outline").random();
    if (region == null)
        return null;
    Image image = new Image(region);
    image.setRotation(-90);
    layer.addActor(image);
    image.setPosition(x * CELL_SIZE, y * CELL_SIZE + image.getWidth());
    return image;
}
 
Example 9
Source File: ViewController.java    From dice-heroes with GNU General Public License v3.0 5 votes vote down vote up
public static Image addTopOutline(int x, int y, String name, Group layer) {
    TextureAtlas.AtlasRegion region = Config.findRegions("tile/" + name + "-outline").random();
    if (region == null)
        return null;
    Image image = new Image(region);
    image.setRotation(90);
    layer.addActor(image);
    image.setPosition((x + 1) * CELL_SIZE, (y + 1) * CELL_SIZE - image.getWidth());
    return image;
}