/* brainGDX project provides utilities for libGDX
 * Copyright (C) 2015 Miguel Gonzalez
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

package de.bitbrain.braingdx.tweens;

import com.badlogic.gdx.graphics.g2d.Sprite;

import aurelienribon.tweenengine.TweenAccessor;

/**
 * Tween facility for sprites
 *
 * @since 1.0.0
 * @version 1.0.0
 * @author Miguel Gonzalez <miguel-gonzalez@gmx.de>
 */
public class SpriteTween implements TweenAccessor<Sprite> {

    public static final int BOUNCE = 1;
    public static final int ALPHA = 2;
    public static final int ROTATION = 3;
    public static final int SCALE = 4;

    @Override
    public int getValues(Sprite target, int tweenType, float[] returnValues) {
        switch (tweenType) {
            case BOUNCE:
                returnValues[0] = target.getY();
                return 1;
            case ALPHA:
                returnValues[0] = target.getColor().a;
                return 1;
            case ROTATION:
                returnValues[0] = target.getRotation();
                return 1;
            case SCALE:
                returnValues[0] = target.getScaleX();
                return 1;
            default:
                return 0;
        }
    }

    @Override
    public void setValues(Sprite target, int tweenType, float[] newValues) {
        switch (tweenType) {
            case BOUNCE:
                target.setY(newValues[0]);
                break;
            case ALPHA:
                target.setAlpha(newValues[0]);
                break;
            case ROTATION:
                target.setRotation(newValues[0]);
                break;
            case SCALE:
                target.setScale(newValues[0]);
                break;
        }
    }

}
@@ -1286,16 +1286,178 @@
 ALE = 4;
+%0A    public static final int COLOR = 5;%0A    public static final int COLOR_R = 6;%0A    public static final int COLOR_G = 7;%0A    public static final int COLOR_B = 8;
 %0A%0A    @O
@@ -2006,533 +2006,1838 @@
     
-default:%0A                return 0;%0A        %7D%0A    %7D%0A%0A    @Override%0A    public void setValues(Sprite target, int tweenType, float%5B%5D newValues) %7B%0A        switch (tweenType) %7B%0A            case BOUNCE:%0A                target.setY(newValues%5B0%5D);%0A                break;%0A            case ALPHA:%0A                target.setAlpha(newValues%5B0%5D);%0A                break;%0A            case ROTATION:%0A                target.setRotation(newValues%5B0%5D);%0A                break;%0A            case SCALE:%0A                target.setScale(newValues%5B0%5D
+case COLOR:%0A                if (returnValues.length == 3) %7B%0A                    returnValues%5B0%5D = target.getColor().r;%0A                    returnValues%5B1%5D = target.getColor().g;%0A                    returnValues%5B2%5D = target.getColor().b;%0A                    return 1;%0A                %7D%0A            case COLOR_R:%0A                returnValues%5B0%5D = target.getColor().r;%0A                return 1;%0A            case COLOR_G:%0A                returnValues%5B0%5D = target.getColor().g;%0A                return 1;%0A            case COLOR_B:%0A                returnValues%5B0%5D = target.getColor().b;%0A                return 1;%0A            default:%0A                return 0;%0A        %7D%0A    %7D%0A%0A    @Override%0A    public void setValues(Sprite target, int tweenType, float%5B%5D newValues) %7B%0A        switch (tweenType) %7B%0A            case BOUNCE:%0A                target.setY(newValues%5B0%5D);%0A                break;%0A            case ALPHA:%0A                target.setAlpha(newValues%5B0%5D);%0A                break;%0A            case ROTATION:%0A                target.setRotation(newValues%5B0%5D);%0A                break;%0A            case SCALE:%0A                target.setScale(newValues%5B0%5D);%0A                break;%0A            case COLOR:%0A                if (newValues.length == 3) %7B%0A                    target.setColor(newValues%5B0%5D, newValues%5B1%5D, newValues%5B2%5D, target.getColor().a);%0A                %7D%0A                break;%0A            case COLOR_R:%0A                target.setColor(newValues%5B0%5D, target.getColor().g, target.getColor().b, target.getColor().a);%0A                break;%0A            case COLOR_G:%0A                target.setColor(target.getColor().r, newValues%5B0%5D, target.getColor().b, target.getColor().a);%0A                break;%0A            case COLOR_B:%0A                target.setColor(target.getColor().r, target.getColor().g, newValues%5B0%5D, target.getColor().a
 );%0A 

Support individual coloring for sprite tweens