All Projects → joshtynjala → gtween.lua

joshtynjala / gtween.lua

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

Programming Languages

lua
6591 projects

Projects that are alternatives of or similar to gtween.lua

COVID-19-DETECTION
Detect Covid-19 with Chest X-Ray Data
Stars: ✭ 43 (+59.26%)
Mutual labels:  corona-sdk
Highway-Dodge
This repo is for a written tutorial commissioned by Envato Tuts+. This tutorial covers how to create a highway dodge game using Corona SDK and the Lua programming language.
Stars: ✭ 22 (-18.52%)
Mutual labels:  corona-sdk
Berry
Berry is a simple Tiled Map Loader for Corona SDK.
Stars: ✭ 16 (-40.74%)
Mutual labels:  corona-sdk
COVID19
A web app to display the live graphical state-wise reported corona cases in India so far. It also shows the latest news for COVID-19. Stay Home, Stay Safe!
Stars: ✭ 122 (+351.85%)
Mutual labels:  corona-sdk

gtween for Corona

The GTween library, originally created by Grant Skinner, ported from ActionScript to Lua for Ansca's Corona SDK by Josh Tynjala.

Usage

For those familiar with Corona, usage is very similar to transition.to(), but gtween offers a variety of useful features that go beyond Corona's built-in transitions. If you've used GTween in ActionScript, then gtween.lua should look very familiar.

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,        -- transition-style easing function
	--ease = gtween.easing.outQuadratic,    -- gtween-style easing function
	repeatCount = math.huge,                -- repeat forever!
	reflect = true,                         -- yoyo
	onChange = redSquareMove_onChange       -- called after every update
})

Easing

Corona uses a different signature for its built-in easing functions than the ones that come with gtween, but gtween can use them with the transitionEase property (see the example above) to tell gtween.lua to use one of the easing functions designed for use with Corona's transitions. Use ease (same as ActionScript) to use one of gtween's easing functions.

The following easing functions are included in gtween.lua, and should be used with the ease property. Some overlap Corona's easing functions, while others are new.

  • gtween.easing.inBack
  • gtween.easing.outBack
  • gtween.easing.inOutBack
  • gtween.easing.inBounce
  • gtween.easing.outBounce
  • gtween.easing.inOutBounce
  • gtween.easing.inCircular
  • gtween.easing.outCircular
  • gtween.easing.inOutCircular
  • gtween.easing.inCubic
  • gtween.easing.outCubic
  • gtween.easing.inOutCubic
  • gtween.easing.inElastic
  • gtween.easing.outElastic
  • gtween.easing.inOutElastic
  • gtween.easing.inExponential
  • gtween.easing.outExponential
  • gtween.easing.inOutExponential
  • gtween.easing.noneLinear
  • gtween.easing.inQuadratic
  • gtween.easing.outQuadratic
  • gtween.easing.inOutQuadratic
  • gtween.easing.inQuartic
  • gtween.easing.outQuartic
  • gtween.easing.inOutQuartic
  • gtween.easing.inQuintic
  • gtween.easing.outQuintic
  • gtween.easing.inOutQuintic
  • gtween.easing.inSine
  • gtween.easing.outSine
  • gtween.easing.inOutSine

Unsupported features

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

  • GTweenTimeline
  • Plugins
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].