lrsordi / java-universal-tween-engine

Automatically exported from code.google.com/p/java-universal-tween-engine
0 stars 0 forks source link

BEGIN callback not called for simple tween. #10

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. see class below

What is the expected output? What do you see instead?

expected:
"hit begin callback"

actual:
"hit callback type 8"

What version of the product are you using? On what operating system?

6.3.2 Ubuntu

Please provide any additional information below.

Not sure if I'm doing something wrong here? It only seems to call the callback 
on COMPLETE, even though I specified to only call at BEGIN.

The class below should illustrate the problem.

Thanks,
felix

import aurelienribon.tweenengine.BaseTween;
import aurelienribon.tweenengine.Tween;
import aurelienribon.tweenengine.TweenAccessor;
import aurelienribon.tweenengine.TweenCallback;
import aurelienribon.tweenengine.TweenManager;

public class Main
{
    private static TweenCallback callbackAtBegin = new TweenCallback()
    {

        @Override
        public void onEvent(int type, BaseTween<?> source)
        {
            if(type == TweenCallback.BEGIN)
                System.out.println("hit begin callback");
            else System.out.println("hit callback type " + type);

        }
    };

    public static void main (String args[]) throws Exception 
    {
        TweenManager manager = new TweenManager();

        Tween.registerAccessor(MyClass.class, myAccessor);

        Tween
            .to(new MyClass(), 0, 1000)
            .target(1f)
            .setCallbackTriggers(TweenCallback.BEGIN)
            .setCallback(callbackAtBegin)
            .start(manager);

        for(int n = 0; n < 1000; n++)
            manager.update(1000f/60f);
    }

    private static class MyClass
    {       
        public float val;
    }

    private static final TweenAccessor<MyClass> myAccessor = new TweenAccessor<Main.MyClass>()
    {       
        @Override
        public void setValues(MyClass target, int tweenType, float[] newValues)
        {
            target.val = newValues[0];
            System.out.println("set value to " + target.val);
        }

        @Override
        public int getValues(MyClass target, int tweenType, float[] returnValues)
        {
            returnValues[0] = target.val;
            return 1;
        }
    };
}

Original issue reported on code.google.com by felixwatts on 22 Jun 2012 at 1:47

GoogleCodeExporter commented 8 years ago
That issue is due to "setCallback" forcing the callback triggers to COMPLETE 
only. Just swap "setCallbackTriggers" and "setCallback" calls and it will be 
fine.

The issue was resolved in a previous commit (aside with a few other bugs), but 
I did not had the time to make an official release of 6.3.3 yet. Coming soon :)

Original comment by aurelien.ribon on 22 Jun 2012 at 1:50

GoogleCodeExporter commented 8 years ago
Thanks for the quick response. The fix worked for me.

:)

Original comment by felixwatts on 22 Jun 2012 at 3:08