Giter Club home page Giter Club logo

gokitlite's Introduction

GoKitLite

GoKitLite is a crazy fast tweening library for Unity. It is optimized for mobile with near zero allocations at runtime. GoKitLite can tween position, localPosition, scale, rotation, localRotation, material color and any properties (float, Vector2, Vector3 or Color). It will tween "to" a value or "from" one to the current value. GoKitLite can also call your own custom Action so that you can tween anything that you want that isn't supported or isnt a property.

GoKitLite usage is dead simple. Below are some examples:

// tween the position of an object to 10, 10, 10 over 1 second
GoKitLite.instance.positionTo( someTransform, 1s, new Vector3( 10, 10, 10 ) );

// tween the rotation of an object to 0, 90, 0 over 0.5 seconds with a custom ease type
GoKitLite.instance.rotationTo( someTransform, 0.5f, new Vector3( 0, 90f, 0 ) )
	.setEaseFunction( GoKitLiteEasing.Back.EaseOut );

// tween the color of a material to red over 1 second with a 3 second delay before starting
GoKitLite.instance.colorTo( someTransform, 1, Color.red, 3 );

Up above we mentioned that you can use a custom Action to handle a tween as well. Here is an example:

// tween the position of an object to 10, 10, 10 over 1 second
GoKitLite.instance.customAction( someTransform, 1s, ( trans, t ) => {
    // do something really cool here like tweening a string or changing multiple objects/properties at once
});

GoKitLite also has a tween chaining system to setup a series of tweens that will all run one after the other. Here is an example alternating position and rotation tweens with a completion handler that will fire when the entire chain is complete:

GoKitLite.instance.positionTo( cube, 0.4f, new Vector3( -8, -3, 0 ) )
	.setEaseFunction( GoKitLiteEasing.Quadratic.EaseInOut )
	.next( GoKitLite.TweenType.Rotation, 0.4f, new Vector3( 90f, 0, 0 ) )
	.next( GoKitLite.TweenType.Position, 0.4f, new Vector3( 1, 2, -5 ) )
	.next( GoKitLite.TweenType.Rotation, 0.4f, new Vector3( 0, 90, 90 ) )
	.next( GoKitLite.TweenType.Position, 0.4f, new Vector3( 0, 0, 0 ) )
	.next( GoKitLite.TweenType.Rotation, 0.4f, new Vector3( 360, 360, 0 ) )
	.setCompletionHandler( trans => { Debug.Log( "Position and Rotation Queue Done" ); } );

Building on the tween chaining system there is also a tween flow system. TweenFlows let you setup a timeline of tweens each with a specific start time. Unlike TweenQueues, tweens in a TweenFlow can be running simultaneously. Here is an example of a position tween that has 4 rotation tweens applied while it is still in transit to it's final position. Note that the start method must be called as a coroutine:

var flow = new GoKitLite.TweenFlow().add( 0, () => { return GoKitLite.instance.positionTo( cube, 5f, new Vector3( 10, 10, 10 ) ); } )
	.add( 1f, () => { return GoKitLite.instance.rotationTo( cube, 0.5f, new Vector3( 90, 0, 0 ) ); } )
	.add( 2f, () => { return GoKitLite.instance.rotationTo( cube, 0.5f, new Vector3( 0, 90, 0 ) ); } )
	.add( 3f, () => { return GoKitLite.instance.rotationTo( cube, 0.5f, new Vector3( 0, 0, 90 ) ); } )
	.add( 4f, () => { return GoKitLite.instance.rotationTo( cube, 0.5f, new Vector3( 180, 180, 180 ) ); } )
	.setCompletionHandler( () => { Debug.Log( "All done with the position/rotation flow" ); } );
StartCoroutine( flow.start() );

GoKitActions

GoKitActions is an optional class that contains additional actions that can be used with GoKitLite's customAction() method:

GoKitLite.instance.customAction( cube, 2, GoKitLiteActions.ShakePosition( cube, 0.6f ), 0, GoKitLiteEasing.Linear.EaseNone );

What about GoKit?

GoKit has a slightly different focus than GoKitLite. It is highly customizeable and can tween anything at all. GoKit has all kinds of nifty features like chains, flows and full tween control in real time that arent ever going to be in GoKitLite. GoKitLite is made for folks who want a really easy API and just want to tween stuff now without much thought.

License

Attribution-NonCommercial-ShareAlike 3.0 Unported with simple explanation with the attribution clause waived. You are free to use GoKitLite in any and all games that you make. You cannot sell GoKitLite directly or as part of a larger game asset.

gokitlite's People

Contributors

prime31 avatar turkerfatih avatar smallfly avatar richy486 avatar

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.