arashbi / java-universal-tween-engine

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

asParallel, asSequence should ignore nulls #1

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
When building animations it would be nice if the asParallel and asSequence 
methods ignored null values.

This would like you do this like this:
TweenGroup.asParallel(
   tween1,
   showTween2 ? tween2 : null,
   showTween3 ? tween3 : null
)

The alternative code is much more cumbersome to generate and less efficient.

This is easily accomplished by changing code from this:
for (int i=0, n=tweens.length; i<n; i++)
            group.groupables.add(tweens[i]);

to:

for (int i = 0, n = tweens.length; i < n; i++) {
    Groupable groupable = tweens[i];
    if (groupable != null) {
        group.groupables.add(groupable);
    }
}

Original issue reported on code.google.com by greg.ara...@gmail.com on 25 Aug 2011 at 1:30

GoogleCodeExporter commented 8 years ago
Waw, I wouldn't have imagined that someone were using the latest sources 
instead of the pre-built releases...(be careful, I may break the API again 
until the 5.0 release, changing from TweenGroup.asParallel(...) to something 
like Parallel.group(...), to enhance maintainability and evolution of groups).

Anyway, I love the idea! I even like it more than that since I myself need to 
add Tweens to sequences depending on conditions in my games. I will handle 
nulls as you proposed, and I'll also add conditional groups, like 
Tweengroup.asParallel(boolean condition, Groupable... groups). That way, you 
will be able to do:

TweenGroup.asParallel(
    tween01,
    ...
    tween10,

    TweenGroup.asParallel(areNexTweensShown,
        tween11,
        ...
        tween20
    ),
).addToManager(manager);

Original comment by aurelien.ribon on 25 Aug 2011 at 7:39

GoogleCodeExporter commented 8 years ago
Thanks for the quick reply.  Normally, I stay away from pre-release software 
unless one of two conditions are met: (1) it's a high quality library, or (2) 
I'm desperate.  In this case, both of these were true :-)  

The current release doesn't let you nest tween groups.  I was ready to make the 
change myself, and then I took a look at the source control log, and much to my 
delight, there it was!  It only took about 5 minutes to change my code to work 
with the new API.  Thanks so very much for creating this project, it's awesome. 
I'm using it to write a game for the Kindle.

I'll send along any bug fixes, or improvements I make as I work on my project. 
Thanks again.

Original comment by greg.ara...@gmail.com on 25 Aug 2011 at 2:02

GoogleCodeExporter commented 8 years ago
Thanks :)
Be careful, there is a bug in the latest sources. Delays of nested groups are 
not computed in the right way, and as a result if you add delays to nested 
groups using .delay(...) method, sequences won't be correctly timed. I'll fix 
everything ASAP.

Original comment by aurelien.ribon on 25 Aug 2011 at 2:09

GoogleCodeExporter commented 8 years ago

Original comment by aurelien.ribon on 26 Aug 2011 at 2:12