Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

joshtynjala/gtween.lua

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 

Repository files navigation

gtween.lua

The GTween library by Grant Skinner ported from ActionScript to Lua and Ansca’s Corona SDK by Josh Tynjala.

Usage

For those familiar with Cornoa, usage is very similar to transition.to, but gtween offers a variety of useful features that go beyond Corona’s built-in transitions.

local gtween = require("gtween")

local redSquare = display.newRect( 0, 0, 100, 100 )
redSquare:setFillColor( 255, 0, 0 )
redSquare.x = 60
redSquare.y = 60

local blueSquare = display.newRect( 0, 0, 100, 100 )
blueSquare:setFillColor( 0, 0, 255 )
blueSquare.x = 170
blueSquare.y = 60
blueSquare.alpha = 0

local function redSquareMove_onChange( tween )
blueSquare.x = redSquare.x + 150
blueSquare.y = redSquare.y
blueSquare.alpha = 1 – redSquare.alpha
end

-[[
gtween.new
Parameters:
1. target
2. duration in seconds
3. table of end values
4. table of gtween properties (separate from tweened values to avoid collisions)
]]
-
gtween.new(redSquare, 1.5,
{
x = 260,
y = 260,
alpha = 0
},
{
transitionEase = easing.outQuad, —standard Corona ease
repeatCount = math.huge, —repeat forever!
reflect = true, —yoyo
onChange = redSquareMove_onChange —called after every update
})

Special Notes

Corona uses a non-standard signature easing functions, but gtween.lua has designed to support them. Use the transitionEase property (see example above) to tell gtween.lua to use one of Corona’s easing functions designed for use with Corona’s transitions. Use ease (same as ActionScript) to use a standard easing function.

Unsupported features

The following features from the original ActionScript GTween are not included in this port. They may be added in the future.

  • GTweenTimeline
  • Plugins
  • Easing functions are not included. See above.

About

Port of Grant Skinner's GTween to Lua for Corona SDK

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages