Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (524)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (592)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Universal Tween Engine -- Give life to your java projects (games, UIs...)  (Read 8483 times)
0 Members and 1 Guest are viewing this topic.
Offline AurelienRibon

Senior Newbie


Medals: 3


Toolmaker, yeah.


« Posted 2011-12-19 14:56:57 »



Hello!

A few months ago, I was desperately in need for an animation library, in order to make nice splash screens and UI animations for my android game. However, while Flash is crawling under powerful tweening engines, there was no such thing for java. Therefore, I made one, open-source, which reached its maturity a few days ago with the release of its 6th major revision.

A tween is basically an interpolation between two values that runs for a given amount of time. Of course, the Tween Engine does a lot more than that, and handles the life-cycles and the update mechanisms of the interpolations for you. Moreover, it enables the interpolation of every attributes from any object in any Java project (being Swing, SWT, OpenGL, Android or even console-based).

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
// In one line, send your object to another position (here x=20 and y=30),
// with a smooth elastic transition, during 1 second (1000ms):
Tween.to(myObject, POSITION, 1000).target(20, 30).ease(Elastic.OUT).start(myManager);

// Also, create complex sequences:
Timeline.createSequence()
    .push(Tween.set(...)) // First, set all objects to their initial positions
    .push(Tween.set(...))
    .push(Tween.set(...))
    .pushPause(1000)      // Wait 1 second
    .push(Tween.to(...))  // Move the objects around, one after the other
    .push(Tween.to(...))
    .push(Tween.to(...))
    .beginParallel()      // Move them all at the same time now
        .push(Tween.to(...))
        .push(Tween.to(...))
        .push(Tween.to(...))
    .end()
    .repeatYoyo(2, 500)   // repeat the whole sequence 2 times
    .start(myManager);    // and finally start it!


Feature set:
  • Zero allocation! Use your project safely on Android without fearing the garbage collector!
  • Supports every interpolation function defined by Robert Penner: http://www.robertpenner.com/easing/
  • Can be used with any object. You just have to implement the TweenAccessor interface when you want interpolation capacities.
  • Every attributes can be interpolated. The only requirement is that what you want to interpolate can be represented as a float number.
  • One line is sufficient to create and start a simple interpolation.
  • Tweens can be easily sequenced thanks to Timelines.
  • Tweens can act on more than one value at a time, so a single tween can change the whole position (X and Y) of a sprite for instance !
  • Tweens and Timelines can be repeated, with a yoyo style option.
  • Many callbacks can be specified (when tweens or timelines complete, start, end, etc.).
  • Simple timers can be built with Tween.call().
  • Source code extensively documented!
  • Wiki documentation to get you started!

Quote

I made two java applets (first one is illustrated below) to let you understand what tweens (and timelines) are, check them out Smiley

Offline Thau

Junior Newbie





« Reply #1 - Posted 2011-12-19 15:26:40 »

Wow this looks amazing, bookmarking for future reference Smiley thanks for making this!
Offline ra4king

JGO Kernel


Medals: 355
Projects: 3
Exp: 5 years


I'm the King!


« Reply #2 - Posted 2012-01-02 15:43:55 »

Now THIS is what we need to compete with Flash Tongue

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline ReBirth
« Reply #3 - Posted 2012-01-02 15:50:13 »

It's already night, but "I'll be back" for this Smiley

Offline ra4king

JGO Kernel


Medals: 355
Projects: 3
Exp: 5 years


I'm the King!


« Reply #4 - Posted 2012-01-02 15:55:20 »

Oh my god, ReBirth are you following me everywhere now?!?

Offline ReBirth
« Reply #5 - Posted 2012-01-03 10:00:43 »

Oh my god, ReBirth are you following me everywhere now?!?
you can't be serious.....  Cranky

Offline AurelienRibon

Senior Newbie


Medals: 3


Toolmaker, yeah.


« Reply #6 - Posted 2012-01-03 10:14:54 »

Thanks guys.

If you really want to compete with Flash, just wait for my next open-source tool: a visual editor for your animation timelines.
It's called the Universal Tween Studio, and will be as generic as the Tween Engine is.

Only thing needed is to implement the "Editor" interface, so the Studio can know what are the different properties of your objects (like "x", "y", "rotation", etc. on the following screenshot). The editor may also be enhanced so you can directly drag your objects in your game and the modifications will be propagated to the Studio, like in the Flash tool.

For now, I will provide 2 implementations of the editor as examples, dedicated to the LibGDX framework: first one is the minimal implementation (5 lines required) so anyone can create his own implementation for any other framework, and second one is an enhanced version with custom drawing (the "recording" red frame visible in the game) and direct object modification with mouse.

Stay tuned Wink



If anyone wonders, yes, it's heavily based on the Expression Blend design, since I love this tool for WPF development. Grin

Offline ReBirth
« Reply #7 - Posted 2012-01-03 10:40:40 »

Yeah I think a desktop tool will be great. In my place it needs lot time to load the applet. However I already know tween's capabilities by looking the library before Wink

Offline Evil-Devil

Senior Devvie


Medals: 2


Fir Tree Master


« Reply #8 - Posted 2012-01-25 13:36:32 »

This is pretty impressive. Is there any example on how to use it with opengl (ie. lwjgl)? Haven't found one in the wiki
Offline AurelienRibon

Senior Newbie


Medals: 3


Toolmaker, yeah.


« Reply #9 - Posted 2012-01-25 13:54:22 »

The library is framework-agnostic. Basically, it interpolates floats from one value to an other. Therefore, these floats can be the x/y/z coordinates of your camera position for instance (to create smooth movements of the camera), or anything else. That's your decision Smiley

For instance, if your camera class is something like:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
public class MyCamera {
   private float x,y,z;
   
   public void setPosition(float dx, float dy, float dz) {
      this.x = x;
      this.y = y;
      this.z = z;
   }
   
   public float getX() {return x;}
   public float getY() {return y;}
   public float getZ() {return z;}
   
   public void apply(GL10 gl) {
      gl.glTranslate(x, y, z);
   }

   ... several opengl related lines of codes...
}


Then, you would implement a TweenAccessor like this:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
public class MyCameraAccessor implements TweenAccessor<MyCamera> {
   public static final int POSITION = 1;

   public int getValues(MyCamera target, int tweenType, float[] returnValues) {
      switch (tweenType) {
         case POSITION:
            returnValues[0] = target.getX();
            returnValues[1] = target.getY();
            returnValues[2] = target.getZ();
            return 3;
      }
   }
   
   public void setValues(MyCamera target, int tweenType, float[] newValues) {
      switch (tweenType) {
         case POSITION:
            target.setPosition(newValues[0], newValues[1], newValues[2];
            break;
      }
   }
}


Only thing needed now is to let the engine know your implementation (required only once, in your initialization code):

1  
Tween.registerAccessor(MyCamera.class, new MyCameraAccessor());


You're done. You can now move your camera smoothly by firing tweens when you want directly on your camera object, like:

1  
Tween.to(myCamera, POSITION, 200).target(1.0f, 2.0f, 0.5f).ease(Back.OUT).start(myManager);

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline AurelienRibon

Senior Newbie


Medals: 3


Toolmaker, yeah.


« Reply #10 - Posted 2012-01-25 13:57:42 »

Also, I recently released a beta version of the Tween Studio library.
The library lets you create your animations using a visual editor like the one in the Flash Authoring Tool or in Microsoft Expression Blend.

More information here: http://www.aurelienribon.com/blog/2012/01/tween-studio-first-public-beta/

i'll make a dedicated topic once it will be polished enough for 1.0 release.


Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

toopeicgaming1999 (57 views)
2014-11-26 15:22:04

toopeicgaming1999 (51 views)
2014-11-26 15:20:36

toopeicgaming1999 (10 views)
2014-11-26 15:20:08

SHC (24 views)
2014-11-25 12:00:59

SHC (24 views)
2014-11-25 11:53:45

Norakomi (27 views)
2014-11-25 11:26:43

Gibbo3771 (24 views)
2014-11-24 19:59:16

trollwarrior1 (37 views)
2014-11-22 12:13:56

xFryIx (75 views)
2014-11-13 12:34:49

digdugdiggy (52 views)
2014-11-12 21:11:50
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!