Example usage for com.badlogic.gdx.graphics.g2d Sprite setRotation

List of usage examples for com.badlogic.gdx.graphics.g2d Sprite setRotation

Introduction

In this page you can find the example usage for com.badlogic.gdx.graphics.g2d Sprite setRotation.

Prototype

public void setRotation(float degrees) 

Source Link

Document

Sets the rotation of the sprite in degrees.

Usage

From source file:CB_Locator.Map.MapViewBase.java

License:Open Source License

protected void renderPositionMarker(Batch batch) {
    PointD point = Descriptor.ToWorld(
            Descriptor.LongitudeToTileX(MapTileLoader.MAX_MAP_ZOOM, Locator.getLongitude()),
            Descriptor.LatitudeToTileY(MapTileLoader.MAX_MAP_ZOOM, Locator.getLatitude()),
            MapTileLoader.MAX_MAP_ZOOM, MapTileLoader.MAX_MAP_ZOOM);

    Vector2 vPoint = new Vector2((float) point.X, -(float) point.Y);

    myPointOnScreen = worldToScreen(vPoint);

    myPointOnScreen.y -= ySpeedVersatz;//from   w  w  w . j  a v a  2s  . c om

    if (showAccuracyCircle) {

        if (accuracyDrawable == null) {
            accuracyDrawable = new AccuracyDrawable(this.mapIntWidth, this.mapIntWidth);
        }

        float radius = (pixelsPerMeter * Locator.getCoordinate().getAccuracy());

        if (radius > GL_UISizes.PosMarkerSize / 2) {
            accuracyDrawable.draw(batch, myPointOnScreen.x, myPointOnScreen.y, radius);
        }
    }

    boolean lastUsedCompass = Locator.UseMagneticCompass();
    boolean Transparency = LocatorSettings.PositionMarkerTransparent.getValue();

    int arrowId = 0;
    if (lastUsedCompass) {
        arrowId = Transparency ? 1 : 0;
    } else {
        arrowId = Transparency ? 3 : 2;
    }

    if (CarMode)
        arrowId = 15;

    Sprite arrow = Sprites.Arrows.get(arrowId);
    arrow.setRotation(-arrowHeading);
    arrow.setBounds(myPointOnScreen.x - GL_UISizes.halfPosMarkerSize,
            myPointOnScreen.y - GL_UISizes.halfPosMarkerSize, GL_UISizes.PosMarkerSize,
            GL_UISizes.PosMarkerSize);
    arrow.setOrigin(GL_UISizes.halfPosMarkerSize, GL_UISizes.halfPosMarkerSize);
    arrow.draw(batch);

}

From source file:CB_UI.GL_UI.Controls.ArrowView.java

License:Open Source License

@Override
public void render(Batch batch) {

    Sprite arrow = Sprites.Arrows.get(0);
    arrow.setRotation(0);
    arrow.setBounds(-(getWidth() / 2), 0, getWidth(), getHeight());
    arrow.setOrigin(this.getCenterPosX(), this.getCenterPosY());
    arrow.draw(batch);/*from   w ww. j a  va2  s .  c om*/

}

From source file:CB_UI.GL_UI.Controls.MapInfoPanel.java

License:Open Source License

private void setArrowDrawable(boolean forceSet) {
    boolean tmp = Locator.UseMagneticCompass();
    if (!forceSet && tmp == lastUsedCompass)
        return;// no change required
    lastUsedCompass = tmp;//w w  w.  j a va  2 s . c  o m
    int arrowId = 0;
    if (lastUsedCompass) {
        arrowId = 0;
    } else {
        arrowId = 2;
    }
    Sprite arrowSprite = new Sprite(Sprites.Arrows.get(arrowId));
    arrowSprite.setRotation(0);// reset rotation
    arrowSprite.setOrigin(0, 0);
    arrow.setDrawable(new SpriteDrawable(arrowSprite));
}

From source file:CB_UI.GL_UI.Views.CompassView.java

License:Open Source License

private void setArrowDrawable(boolean forceSet) {
    boolean tmp = Locator.UseMagneticCompass();
    if (!forceSet && tmp == lastUsedCompass)
        return;// no change required
    lastUsedCompass = tmp;/*  w w w  .  j  a  v a2s .co  m*/

    int arrowId = 0;
    if (lastUsedCompass) {
        arrowId = 0;
    } else {
        arrowId = 2;
    }
    Sprite arrowSprite = new Sprite(Sprites.Arrows.get(arrowId));
    arrowSprite.setRotation(0);// reset rotation
    arrowSprite.setOrigin(0, 0);
    arrow.setDrawable(new SpriteDrawable(arrowSprite));
}

From source file:CB_UI.GL_UI.Views.MapView.java

License:Open Source License

private void RenderTargetArrow(Batch batch) {

    if (GlobalCore.getSelectedCache() == null)
        return;/* ww w  .j  av  a2s  .com*/

    Coordinate coord = (GlobalCore.getSelectedWaypoint() != null) ? GlobalCore.getSelectedWaypoint().Pos
            : GlobalCore.getSelectedCache().Pos;

    if (coord == null) {
        return;
    }
    float x = (float) (256.0 * Descriptor.LongitudeToTileX(MapTileLoader.MAX_MAP_ZOOM, coord.getLongitude()));
    float y = (float) (-256.0 * Descriptor.LatitudeToTileY(MapTileLoader.MAX_MAP_ZOOM, coord.getLatitude()));

    float halfHeight = (mapIntHeight / 2) - ySpeedVersatz;
    float halfWidth = mapIntWidth / 2;

    // create ScreenRec
    try {
        if (TargetArrowScreenRec == null) {
            TargetArrowScreenRec = new CB_RectF(0, 0, mapIntWidth, mapIntHeight);
            if (Mode != MapMode.Compass) {
                TargetArrowScreenRec.ScaleCenter(0.9f);

                if (Mode == MapMode.Normal) {
                    TargetArrowScreenRec.setHeight(TargetArrowScreenRec.getHeight()
                            - (TargetArrowScreenRec.getHeight() - info.getY()) - zoomBtn.getHeight());
                    TargetArrowScreenRec.setY(zoomBtn.getMaxY());
                }
            }
        }

        Vector2 ScreenCenter = new Vector2(halfWidth, halfHeight);

        Vector2 screen = worldToScreen(new Vector2(x, y));
        Vector2 target = new Vector2(screen.x, screen.y);

        Vector2 newTarget = TargetArrowScreenRec.getIntersection(ScreenCenter, target);

        // Rotation berechnen
        if (newTarget != null) {

            float direction = get_angle(ScreenCenter.x, ScreenCenter.y, newTarget.x, newTarget.y);
            direction = 180 - direction;

            // draw sprite
            Sprite arrow = Sprites.Arrows.get(4);
            arrow.setRotation(direction);

            float boundsX = newTarget.x - GL_UISizes.TargetArrow.halfWidth;
            float boundsY = newTarget.y - GL_UISizes.TargetArrow.height;

            arrow.setBounds(boundsX, boundsY, GL_UISizes.TargetArrow.width, GL_UISizes.TargetArrow.height);

            arrow.setOrigin(GL_UISizes.TargetArrow.halfWidth, GL_UISizes.TargetArrow.height);
            arrow.draw(batch);

            // get real bounding box of TargetArrow
            float t[] = arrow.getVertices();
            float maxX = Math.max(Math.max(t[0], t[5]), Math.max(t[10], t[15]));
            float minX = Math.min(Math.min(t[0], t[5]), Math.min(t[10], t[15]));
            float maxY = Math.max(Math.max(t[1], t[6]), Math.max(t[11], t[16]));
            float minY = Math.min(Math.min(t[1], t[6]), Math.min(t[11], t[16]));
            TargetArrow.set(minX, minY, maxX - minX, maxY - minY);
        } else {
            TargetArrow.set(0, 0, 0, 0);
        }
    } catch (Exception e) {
        TargetArrow.set(0, 0, 0, 0);
    }
}

From source file:CB_UI.GL_UI.Views.MapView.java

License:Open Source License

public void renderWPI(Batch batch, SizeF WpUnderlay, SizeF WpSize, WaypointRenderInfo wpi) {
    Vector2 screen = worldToScreen(new Vector2(wpi.MapX, wpi.MapY));

    screen.y -= ySpeedVersatz;/*w  w w.  jav a2 s . com*/
    // FIXME create a LineDrawable class for create one times and set the Coordinates with calculated Triangles
    if (myPointOnScreen != null && showDirectLine && (wpi.Selected)
            && (wpi.Waypoint == GlobalCore.getSelectedWaypoint())) {
        // FIXME render only if visible on screen (intersect the screen rec)
        Quadrangle line = new Quadrangle(myPointOnScreen.x, myPointOnScreen.y, screen.x, screen.y,
                3 * UI_Size_Base.that.getScale());
        if (paint == null) {
            paint = new GL_Paint();
            paint.setGLColor(Color.RED);
        }
        PolygonDrawable po = new PolygonDrawable(line.getVertices(), line.getTriangles(), paint,
                this.mapIntWidth, this.mapIntHeight);
        po.draw(batch, 0, 0, this.mapIntWidth, this.mapIntHeight, 0);
        po.dispose();
    }
    // Don't render if outside of screen !!
    if ((screen.x < 0 - WpSize.width || screen.x > this.getWidth() + WpSize.height)
            || (screen.y < 0 - WpSize.height || screen.y > this.getHeight() + WpSize.height)) {
        if (wpi.Cache != null && (wpi.Cache.Id == infoBubble.getCacheId()) && infoBubble.isVisible()) {
            // check if wp selected
            if (wpi.Waypoint != null && wpi.Waypoint.equals(infoBubble.getWaypoint())
                    || wpi.Waypoint == null && infoBubble.getWaypoint() == null)
                infoBubble.setInvisible();
        }
        return;
    }

    float NameYMovement = 0;

    if ((aktZoom >= zoomCross) && (wpi.Selected) && (wpi.Waypoint == GlobalCore.getSelectedWaypoint())) {
        // Draw Cross and move screen vector
        Sprite cross = Sprites.MapOverlay.get(3);
        cross.setBounds(screen.x - WpUnderlay.halfWidth, screen.y - WpUnderlay.halfHeight, WpUnderlay.width,
                WpUnderlay.height);
        cross.draw(batch);

        screen.add(-WpUnderlay.width, WpUnderlay.height);
        NameYMovement = WpUnderlay.height;
    }

    if (wpi.UnderlayIcon != null) {
        wpi.UnderlayIcon.setBounds(screen.x - WpUnderlay.halfWidth, screen.y - WpUnderlay.halfHeight,
                WpUnderlay.width, WpUnderlay.height);
        wpi.UnderlayIcon.draw(batch);
    }
    if (wpi.Icon != null) {
        wpi.Icon.setBounds(screen.x - WpSize.halfWidth, screen.y - WpSize.halfHeight, WpSize.width,
                WpSize.height);
        wpi.Icon.draw(batch);
    }

    // draw Favorite symbol
    if (wpi.Cache != null && wpi.Cache.isFavorite()) {
        batch.draw(Sprites.getSprite(IconName.favorit.name()), screen.x + (WpSize.halfWidth / 2),
                screen.y + (WpSize.halfHeight / 2), WpSize.width, WpSize.height);
    }

    if (wpi.OverlayIcon != null) {
        wpi.OverlayIcon.setBounds(screen.x - WpUnderlay.halfWidth, screen.y - WpUnderlay.halfHeight,
                WpUnderlay.width, WpUnderlay.height);
        wpi.OverlayIcon.draw(batch);
    }

    boolean drawAsWaypoint = wpi.Waypoint != null;

    // Rating des Caches darstellen
    if (wpi.Cache != null && showRating && (!drawAsWaypoint) && (wpi.Cache.Rating > 0) && (aktZoom >= 15)) {
        Sprite rating = Sprites.MapStars.get((int) Math.min(wpi.Cache.Rating * 2, 5 * 2));
        rating.setBounds(screen.x - WpUnderlay.halfWidth,
                screen.y - WpUnderlay.halfHeight - WpUnderlay.Height4_8, WpUnderlay.width,
                WpUnderlay.Height4_8);
        rating.setOrigin(WpUnderlay.width / 2, WpUnderlay.Height4_8 / 2);
        rating.setRotation(0);
        rating.draw(batch);
        NameYMovement += WpUnderlay.Height4_8;
    }

    // Beschriftung
    if (wpi.Cache != null && showTitles && (aktZoom >= 15)) {
        try {
            String Name = drawAsWaypoint ? wpi.Waypoint.getTitle() : wpi.Cache.getName();

            if (layout == null)
                layout = new GlyphLayout(Fonts.getNormal(), Name);
            else
                layout.setText(Fonts.getNormal(), Name);

            float halfWidth = layout.width / 2;
            Fonts.getNormal().draw(batch, layout, screen.x - halfWidth,
                    screen.y - WpUnderlay.halfHeight - NameYMovement);
        } catch (Exception e) {
        }
    }

    // Show D/T-Rating
    if (wpi.Cache != null && showDT && (!drawAsWaypoint) && (aktZoom >= 15)) {
        Sprite difficulty = Sprites.MapStars.get((int) Math.min(wpi.Cache.getDifficulty() * 2, 5 * 2));
        difficulty.setBounds(screen.x - WpUnderlay.width - GL_UISizes.infoShadowHeight,
                screen.y - (WpUnderlay.Height4_8 / 2), WpUnderlay.width, WpUnderlay.Height4_8);
        difficulty.setOrigin(WpUnderlay.width / 2, WpUnderlay.Height4_8 / 2);
        difficulty.setRotation(90);
        difficulty.draw(batch);

        Sprite terrain = Sprites.MapStars.get((int) Math.min(wpi.Cache.getTerrain() * 2, 5 * 2));
        terrain.setBounds(screen.x + GL_UISizes.infoShadowHeight, screen.y - (WpUnderlay.Height4_8 / 2),
                WpUnderlay.width, WpUnderlay.Height4_8);
        terrain.setOrigin(WpUnderlay.width / 2, WpUnderlay.Height4_8 / 2);
        terrain.setRotation(90);
        terrain.draw(batch);

    }

    if (wpi.Cache != null && (wpi.Cache.Id == infoBubble.getCacheId()) && infoBubble.isVisible()) {
        if (infoBubble.getWaypoint() == wpi.Waypoint) {
            Vector2 pos = new Vector2(screen.x - infoBubble.getHalfWidth(), screen.y);
            infoBubble.setPos(pos);
        }
    }
}

From source file:CB_UI_Base.GL_UI.Controls.ZoomButtons.java

License:Open Source License

@Override
public void render(Batch batch) {
    if (withoutDrawing)
        return;//from   ww w  . j a v a  2 s . c  om
    super.render(batch);

    if (firstDraw) {
        resetFadeOut();
        firstDraw = false;
    }

    if (!this.isVisible())
        return;
    // Log.d("CACHEBOX", "in=" + fadeIn + " out=" + fadeOut + " Fade=" + FadeValue);
    checkFade();

    // draw down button
    Sprite btnDown;
    if (zoom == minzoom) {
        btnDown = Sprites.ZoomBtn.get(2);// disabled
    } else {
        btnDown = Sprites.ZoomBtn.get(onTouchDown ? 1 : 0);
    }

    float hw = HitRecDown.getWidth();
    float hh = HitRecDown.getHeight();
    float hx = HitRecDown.getX();
    float hy = HitRecDown.getY();
    float offX = 0;
    float offY = 0;

    if (portrait) {
        float e = btnDown.getWidth() / 2;
        float f = btnDown.getHeight() / 2;

        btnDown.setOrigin(e, f);
        btnDown.setRotation(90);

        hw = hh;
        hh = HitRecDown.getWidth();

        // caclc offset
        offX = -(e - f);
        offY = -(f - e);
    } else {
        btnDown.setRotation(0f);
    }

    btnDown.setBounds(hx + offX, hy + offY, hw, hh);
    btnDown.draw(batch, FadeValue);

    // draw up button
    Sprite btnUp;
    if (zoom == maxzoom) {
        btnUp = Sprites.ZoomBtn.get(5);// disabled
    } else {
        btnUp = Sprites.ZoomBtn.get(onTouchUp ? 4 : 3);
    }

    hw = HitRecUp.getWidth();
    hh = HitRecUp.getHeight();
    hx = HitRecUp.getX();
    hy = HitRecUp.getY();

    if (portrait) {
        float e = btnUp.getWidth() / 2;
        float f = btnUp.getHeight() / 2;
        btnUp.setOrigin(e, f);
        btnUp.setRotation(90);

        hw = hh;
        hh = HitRecUp.getWidth();
    } else {
        btnUp.setRotation(0f);
    }

    btnUp.setBounds(hx + offX, hy + offY, hw, hh);
    btnUp.draw(batch, FadeValue);
}

From source file:com.binarytenshi.nopassing.core.environment.StreetHandler.java

private static Sprite getSprite(int x, int y) {
    Sprite sprite = new Sprite(streetTexture, 0, 0, TextureLib.tileSide, TextureLib.tileSide);

    // up, right, down, left (0b0000)
    byte orientation = getOrientation(x, y);

    switch (orientation) {
    // DEFAULT; UP DOWN
    case 0b0000:/*  ww w  .  j a v  a  2  s.  co  m*/
    case 0b1000:
    case 0b0010:
    case 0b1010:
        sprite.setRegion(0, 0, TextureLib.tileSide, TextureLib.tileSide);
        break;

    // LEFT RIGHT
    case 0b0101:
    case 0b0100:
    case 0b0001:
        sprite.setRegion(0, 0, TextureLib.tileSide, TextureLib.tileSide);
        sprite.setRotation(90f);
        break;

    // DOWN LEFT
    case 0b0011:
        sprite.setRegion(TextureLib.tileSide, 0, TextureLib.tileSide, TextureLib.tileSide);
        break;

    // RIGHT DOWN
    case 0b0110:
        sprite.setRegion(TextureLib.tileSide, 0, TextureLib.tileSide, TextureLib.tileSide);
        sprite.rotate(-90f);
        break;

    // UP RIGHT
    case 0b1100:
        sprite.setRegion(TextureLib.tileSide, 0, TextureLib.tileSide, TextureLib.tileSide);
        sprite.rotate(180f);
        break;

    // UP LEFT
    case 0b1001:
        sprite.setRegion(TextureLib.tileSide, 0, TextureLib.tileSide, TextureLib.tileSide);
        sprite.rotate(90f);
        break;

    // UP RIGHT DOWN
    case 0b1110:
        sprite.setRegion(0, TextureLib.tileSide, TextureLib.tileSide, TextureLib.tileSide);
        break;

    // UP RIGHT LEFT
    case 0b1101:
        sprite.setRegion(0, TextureLib.tileSide, TextureLib.tileSide, TextureLib.tileSide);
        sprite.rotate(-90f);
        break;

    // RIGHT DOWN LEFT
    case 0b0111:
        sprite.setRegion(0, TextureLib.tileSide, TextureLib.tileSide, TextureLib.tileSide);
        sprite.rotate(90f);
        break;

    // UP DOWN LEFT
    case 0b1011:
        sprite.setRegion(0, TextureLib.tileSide, TextureLib.tileSide, TextureLib.tileSide);
        sprite.rotate(180f);
        break;

    // UP RIGHT DOWN LEFT
    case 0b1111:
        sprite.setRegion(TextureLib.tileSide, TextureLib.tileSide, TextureLib.tileSide, TextureLib.tileSide);
        break;
    }

    return sprite;
}

From source file:com.example.squarejam.HelpAnimation.java

License:Open Source License

public static void start(List<Sprite> displayList, TweenManager manager, Texture dark_hand, Texture light_hand,
        Texture medium_hand, Texture tan_hand, Texture texBlue, Texture texGreen, Texture texPurple,
        Texture texOrange, Texture tablet, Texture help_bg) {
    final float squareApparitionDelay = 0.3f;
    final float squareApparitionTime = 1.3f;
    final float squareDelayBetweenApparitions = 0.5f;

    final float squareSlideDelay = squareApparitionDelay + squareDelayBetweenApparitions * 3
            + squareApparitionTime + 0.8f;
    final float squareSlideTime = 2.2f;
    final float squareDelayBetweenSlides = 0.7f;

    final float tabletApparitionDelay = squareSlideDelay + squareDelayBetweenSlides * 3 + squareSlideTime
            + -0.3f;//from   w ww.j a  va 2s .  co m
    final float tabletApparitionTime = 1.1f;

    final float handApparitionDelay = tabletApparitionDelay + tabletApparitionTime + 0.3f;
    //TODO list other hand timings

    float w = Gdx.graphics.getWidth();
    float h = Gdx.graphics.getHeight();

    //TODO condense into methods

    TextureRegion region = new TextureRegion(help_bg, 0, 0, 1024, 1024);

    Sprite bgSprite = new Sprite(region);

    bgSprite.setSize(1, 1);
    bgSprite.setOrigin(bgSprite.getWidth() / 2.0f, bgSprite.getHeight() / 2.0f);
    bgSprite.setPosition(-0.5f, -0.5f);

    displayList.add(bgSprite);

    //Add purple square and animate
    region = new TextureRegion(texPurple, 0, 0, 1, 1);

    Sprite purpleSprite = new Sprite(region);

    purpleSprite.setSize(0.15f, 0.15f);
    purpleSprite.setOrigin(purpleSprite.getWidth() / 2.0f, purpleSprite.getHeight() / 2.0f);
    purpleSprite.setPosition(-0.075f, 0.1f);

    displayList.add(purpleSprite);

    Tween.set(purpleSprite, SpriteAccessor.SIZE_XY).target(0, 0).start(manager);

    Tween.to(purpleSprite, SpriteAccessor.SIZE_XY, squareApparitionTime).target(1, 1)
            .delay(squareApparitionDelay + squareDelayBetweenApparitions * 0).start(manager);

    //Add blue square and animate
    region = new TextureRegion(texBlue, 0, 0, 1, 1);

    Sprite blueSprite = new Sprite(region);

    blueSprite.setSize(0.15f, 0.15f);
    blueSprite.setOrigin(blueSprite.getWidth() / 2.0f, blueSprite.getHeight() / 2.0f);
    blueSprite.setPosition(-0.25f, -0.075f);

    displayList.add(blueSprite);

    Tween.set(blueSprite, SpriteAccessor.SIZE_XY).target(0, 0).start(manager);

    Tween.to(blueSprite, SpriteAccessor.SIZE_XY, squareApparitionTime).target(1, 1)
            .delay(squareApparitionDelay + squareDelayBetweenApparitions * 1).start(manager);

    //Add orange square and animate
    region = new TextureRegion(texOrange, 0, 0, 1, 1);

    Sprite orangeSprite = new Sprite(region);

    orangeSprite.setSize(0.15f, 0.15f);
    orangeSprite.setOrigin(orangeSprite.getWidth() / 2.0f, orangeSprite.getHeight() / 2.0f);
    orangeSprite.setPosition(0.1f, -0.075f);

    displayList.add(orangeSprite);

    Tween.set(orangeSprite, SpriteAccessor.SIZE_XY).target(0, 0).start(manager);

    Tween.to(orangeSprite, SpriteAccessor.SIZE_XY, squareApparitionTime).target(1, 1)
            .delay(squareApparitionDelay + squareDelayBetweenApparitions * 2).start(manager);

    //Add green square and animate
    region = new TextureRegion(texGreen, 0, 0, 1, 1);

    Sprite greenSprite = new Sprite(region);

    greenSprite.setSize(0.15f, 0.15f);
    greenSprite.setOrigin(greenSprite.getWidth() / 2.0f, greenSprite.getHeight() / 2.0f);
    greenSprite.setPosition(-0.075f, -0.25f);

    displayList.add(greenSprite);

    Tween.set(greenSprite, SpriteAccessor.SIZE_XY).target(0, 0).start(manager);

    Tween.to(greenSprite, SpriteAccessor.SIZE_XY, squareApparitionTime).target(1, 1)
            .delay(squareApparitionDelay + squareDelayBetweenApparitions * 3).start(manager);

    //Slides
    Tween.to(purpleSprite, SpriteAccessor.POSITION_Y, squareSlideTime).target(1.1f)
            .delay(squareSlideDelay + squareDelayBetweenSlides * 0).start(manager);

    Tween.to(blueSprite, SpriteAccessor.POSITION_X, squareSlideTime).target(-1.25f)
            .delay(squareSlideDelay + squareDelayBetweenSlides * 1).start(manager);

    Tween.to(orangeSprite, SpriteAccessor.POSITION_X, squareSlideTime).target(1.1f)
            .delay(squareSlideDelay + squareDelayBetweenSlides * 2).start(manager);

    Tween.to(greenSprite, SpriteAccessor.POSITION_Y, squareSlideTime).target(-1.25f)
            .delay(squareSlideDelay + squareDelayBetweenSlides * 3).start(manager);

    //Add Tablet and animate 
    region = new TextureRegion(tablet, 0, 0, 512, 386);

    Sprite tabSprite = new Sprite(region);

    tabSprite.setSize(0.5f, 386.0f / 512.0f / 2.0f);
    tabSprite.setOrigin(tabSprite.getWidth() / 2, tabSprite.getHeight() / 2);
    tabSprite.setPosition(-0.25f, h / w / 2);

    displayList.add(tabSprite);

    Tween.to(tabSprite, SpriteAccessor.POSITION_XY, tabletApparitionTime).target(-0.25f, -0.2f)
            .ease(Cubic.INOUT).delay(tabletApparitionDelay).start(manager);

    //Add dark hand and animate
    region = new TextureRegion(dark_hand, 120, 0, 256, 256);

    Sprite dhSprite = new Sprite(region);

    dhSprite.setSize(0.25f, 0.25f);
    dhSprite.setOrigin(0.09f, 0.23f);
    dhSprite.setPosition(0, 0.3f);
    dhSprite.setRotation(180);

    displayList.add(dhSprite);

    Tween.to(dhSprite, SpriteAccessor.POSITION_XY, 1.3f).target(0.07f, -0.13f).delay(handApparitionDelay + 0.2f)
            .start(manager);

    Tween.to(dhSprite, SpriteAccessor.POSITION_XY, 1.3f).target(-0.03f, -0.33f)
            .delay(handApparitionDelay + 2.3f).start(manager);

    Tween.to(dhSprite, SpriteAccessor.POSITION_XY, 1.0f).target(0.07f, -0.33f).delay(handApparitionDelay + 4.4f)
            .start(manager);

    Tween.to(dhSprite, SpriteAccessor.POSITION_XY, 2.0f).target(-0.07f, 0.03f).delay(handApparitionDelay + 6.5f)
            .start(manager);

    //Add light hand and animate
    region = new TextureRegion(light_hand, 120, 0, 256, 256);

    Sprite lhSprite = new Sprite(region);

    lhSprite.setSize(0.25f, 0.25f);
    lhSprite.setOrigin(0.09f, 0.23f);
    lhSprite.setPosition(-0.7f, 0.0f);
    lhSprite.setRotation(270);

    displayList.add(lhSprite);

    Tween.to(lhSprite, SpriteAccessor.POSITION_XY, 2.3f).target(-0.03f, -0.13f).delay(handApparitionDelay)
            .start(manager);

    Tween.to(lhSprite, SpriteAccessor.POSITION_XY, 1.3f).target(-0.25f, -0.23f)
            .delay(handApparitionDelay + 3.1f).start(manager);

    Tween.to(lhSprite, SpriteAccessor.POSITION_XY, 1.0f).target(-0.5f, -0.25f).delay(handApparitionDelay + 5.2f)
            .start(manager);

    //Add tan hand and animate
    region = new TextureRegion(tan_hand, 120, 0, 256, 256);

    Sprite thSprite = new Sprite(region);

    thSprite.setSize(0.25f, 0.25f);
    thSprite.setOrigin(0.09f, 0.23f);
    thSprite.setPosition(0.5f, -0.2f);
    thSprite.setRotation(90);

    displayList.add(thSprite);

    Tween.to(thSprite, SpriteAccessor.POSITION_XY, 2.0f).target(-0.03f, -0.23f)
            .delay(handApparitionDelay + 0.1f).start(manager);

    Tween.to(thSprite, SpriteAccessor.POSITION_XY, 1.2f).target(-0.13f, -0.25f)
            .delay(handApparitionDelay + 2.5f).start(manager);

    Tween.to(thSprite, SpriteAccessor.POSITION_XY, 1.2f).target(-0.13f, -0.14f)
            .delay(handApparitionDelay + 3.8f).start(manager);

    Tween.to(thSprite, SpriteAccessor.POSITION_XY, 1.5f).target(-0.23f, -0.35f)
            .delay(handApparitionDelay + 6.0f).start(manager);

    Tween.to(thSprite, SpriteAccessor.POSITION_XY, 2.0f).target(0.3f, -0.2f).delay(handApparitionDelay + 8.1f)
            .start(manager);

    //Add medium hand and animate
    region = new TextureRegion(medium_hand, 120, 0, 256, 256);

    Sprite mhSprite = new Sprite(region);

    mhSprite.setSize(0.25f, 0.25f);
    mhSprite.setOrigin(0.09f, 0.23f);
    mhSprite.setPosition(0.0f, -0.6f);

    displayList.add(mhSprite);

    Tween.to(mhSprite, SpriteAccessor.POSITION_XY, 1.8f).target(-0.13f, -0.33f)
            .delay(handApparitionDelay + 0.4f).start(manager);

    Tween.to(mhSprite, SpriteAccessor.POSITION_XY, 1.4f).target(0.07f, -0.23f).delay(handApparitionDelay + 3.3f)
            .start(manager);

    Tween.to(mhSprite, SpriteAccessor.POSITION_XY, 2.0f).target(-0.25f, -0.13f)
            .delay(handApparitionDelay + 5.5f).start(manager);

    Tween.to(mhSprite, SpriteAccessor.POSITION_XY, 2.0f).target(0.0f, -0.5f).delay(handApparitionDelay + 8.1f)
            .start(manager);
}

From source file:com.example.squarejam.SpriteAccessor.java

License:Open Source License

@Override
public void setValues(Sprite target, int tweenType, float[] newValues) {
    switch (tweenType) {
    case SIZE_X://www .  j  a  v  a 2  s. c  o m
        target.setScale(newValues[0], target.getScaleY());
        break;
    case SIZE_Y:
        target.setScale(target.getScaleX(), newValues[0]);
        break;
    case SIZE_XY:
        target.setScale(newValues[0], newValues[1]);
        break;

    case POSITION_X:
        target.setPosition(newValues[0], target.getY());
        break;
    case POSITION_Y:
        target.setPosition(target.getX(), newValues[0]);
        break;
    case POSITION_XY:
        target.setPosition(newValues[0], newValues[1]);
        break;

    case ROTATION:
        target.setRotation(newValues[0]);
        break;
    case OPACITY:
        target.setColor(target.getColor().r, target.getColor().g, target.getColor().b, newValues[0]);
        break;

    default:
        assert false;
        break;
    }
}