Skip to content

Commit

Permalink
Merge branch 'release/1.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
Sunjammer committed Aug 22, 2015
2 parents b10e73d + 1a0011a commit b2d940a
Show file tree
Hide file tree
Showing 8 changed files with 417 additions and 185 deletions.
116 changes: 59 additions & 57 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,64 +10,66 @@ Inspired, of course, by the standards, TweenLite and Actuate. Tween functions ad

Key API difference from Actuate is Delta defines "a tween" as a linked list of Tween actions, which is consumed action by action until the full list is empty. This means tweens are inherently sequenced, allowing the rapid creaton of sequences of tweens. It also allows for some synchronization, such as one tween sequence waiting for a trigger ID before proceeding, which can be dispatched either from another tween sequence, or from Delta itself.

Ease functions are simplified to the signature Float->Float->Float->Float...
Ease functions are simplified to the signature `Float->Float->Float->Float`...

Delta.tween(myObject).ease( function(startValue:Float, deltaValue:Float, t:Float):Float
```haxe
Delta.tween(myObject).ease( function(startValue:Float, deltaValue:Float, t:Float):Float
```
... where `startValue` is the initial value, `deltaValue` is the difference between the start value and the target value, and `t` is a scalar between 0 and 1.

...where startValue is the initial value, deltaValue is the difference between the start value and the target value, and t is a scalar between 0 and 1.
```haxe
package ;
import flash.display.Sprite;
import flash.events.Event;
import flash.Lib;
import tween.Delta;
import tween.easing.Quad;
import tween.easing.Sine;
import tween.utils.Stopwatch;
package ;

import flash.display.Sprite;
import flash.events.Event;
import flash.Lib;
import tween.Delta;
import tween.easing.Quad;
import tween.easing.Sine;
import tween.utils.Stopwatch;

class Main extends Sprite
{
var obj1:Sprite;
var obj2:Sprite;
public function new()
{
super();
obj1 = new Sprite();
obj1.graphics.beginFill(0xFF0000);
obj1.graphics.drawRect(0, 0, 50, 50);
obj2 = new Sprite();
obj2.graphics.beginFill(0x00FF00);
obj2.graphics.drawRect(0, 0, 50, 50);
obj2.x = 400;
addChild(obj1);
addChild(obj2);
Delta.tween(obj1) //Begin a tween with obj1
.wait(1.0) //wait for 1 second
.prop("x", 50, 1.0) //Tween x to 50 over 1 second
.prop("y", 50, 1.0).ease(Sine.easeInOut, false) //Do the same with y, but apply a sine ease to *that component* of the tween
.wait(1.0) //Wait another second
.tween(obj2) //Create another tween target
.propMultiple( { x:0, y:0 }, 0.5) //Tween both x and y to 0 over .5 seconds
.ease(Quad.easeOut) //Apply a Quad ease to all components of that ease (so far)
.onComplete(function() { trace("Done"); } ); //Finally report completion
addEventListener(Event.ENTER_FRAME, update);
}
private function update(e:Event):Void
{
Delta.step(Stopwatch.tock()); //Update the tween engine with a delta in seconds using the stopwatch util
Stopwatch.tick(); //store frame time for next tock
}
static function main()
{
Lib.current.addChild(new Main());
}
}
class Main extends Sprite
{
var obj1:Sprite;
var obj2:Sprite;
public function new()
{
super();
obj1 = new Sprite();
obj1.graphics.beginFill(0xFF0000);
obj1.graphics.drawRect(0, 0, 50, 50);
obj2 = new Sprite();
obj2.graphics.beginFill(0x00FF00);
obj2.graphics.drawRect(0, 0, 50, 50);
obj2.x = 400;
addChild(obj1);
addChild(obj2);
Delta.tween(obj1) //Begin a tween with obj1
.wait(1.0) //Wait for 1 second
.prop("x", 50, 1.0) //Tween x to 50 over 1 second
.prop("y", 50, 1.0).ease(Sine.easeInOut, false) //Do the same with y, but apply a sine ease to *that component* of the tween
.wait(1.0) //Wait another second
.tween(obj2) //Create another tween target
.propMultiple( { x:0, y:0 }, 0.5) //Tween both x and y to 0 over .5 seconds
.ease(Quad.easeOut) //Apply a Quad ease to all components of that ease (so far)
.onComplete(function() { trace("Done"); } ); //Finally report completion
addEventListener(Event.ENTER_FRAME, update);
}
private function update(e:Event):Void
{
Delta.step(Stopwatch.tock()); //Update the tween engine with a delta in seconds using the stopwatch util
Stopwatch.tick(); //Store frame time for next tock
}
static function main()
{
Lib.current.addChild(new Main());
}
}
```
Loading

0 comments on commit b2d940a

Please sign in to comment.