Code Monkey home page Code Monkey logo

delta's Introduction

delta

Game-focused Tweening library for Haxe 3

Primary purpose is simply to have better control of timing issues. Secondary goals are syntactic: Provide a nice quick way to control and synchronize animations of float properties.

Inspired, of course, by the standards, TweenLite and Actuate. Tween functions adapted from Actuate's adaptions of The Classics.

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...

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.

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());
	}
}

delta's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

delta's Issues

[question/request] can delta do manual update?

just to ask. could or can delta do manual update.

asking as I have tried different tweens within different states with different updates etc. but want to not have a global acting tween update. only fires off when a state is using a tween for that state

Error when using Quint

When trying to import Quint, there seems to be an undeclared variable. Following output when importing Quint with no DCE:
Quint.hx:22: characters 42-43 : Unknown identifier : b

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.