Difference between revisions of "GTween"
From GiderosMobile
(WIP) |
|||
| Line 27: | Line 27: | ||
'''Note''': GTween uses the '''Easing''' plugin so make sure to add it to your project Plugins | '''Note''': GTween uses the '''Easing''' plugin so make sure to add it to your project Plugins | ||
| − | === | + | === Example === |
| − | |||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
--[[ | --[[ | ||
| Line 56: | Line 55: | ||
} | } | ||
) | ) | ||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
</syntaxhighlight> | </syntaxhighlight> | ||
| Line 109: | Line 60: | ||
'''[[Ftf_libs#GFX]]'''</br> | '''[[Ftf_libs#GFX]]'''</br> | ||
'''[[Easing]]'''</br> | '''[[Easing]]'''</br> | ||
| + | |||
{|- | {|- | ||
| style="width: 50%; vertical-align:top;"| | | style="width: 50%; vertical-align:top;"| | ||
| Line 114: | Line 66: | ||
=== Methods === | === Methods === | ||
[[GTween.new]] ''creates a new GTween''<br/><!--GIDEROSMTD:GTween.new(target,duration,values,props) creates a new GTween--> | [[GTween.new]] ''creates a new GTween''<br/><!--GIDEROSMTD:GTween.new(target,duration,values,props) creates a new GTween--> | ||
| − | [[GTween:getColor]] ''returns the color(s) of the Pixel''<br/><!--GIDEROSMTD:Pixel:getColor() gets the color(s) of the Pixel--> | + | <!--[[GTween:getColor]] ''returns the color(s) of the Pixel''<br/><!--GIDEROSMTD:Pixel:getColor() gets the color(s) of the Pixel-->--> |
| − | [[GTween:getDimensions]] ''returns the current size of the Pixel''<br/><!--GIDEROSMTD:Pixel:getDimensions() returns the current size of the Pixel--> | + | <!--[[GTween:getDimensions]] ''returns the current size of the Pixel''<br/><!--GIDEROSMTD:Pixel:getDimensions() returns the current size of the Pixel-->--> |
| style="width: 50%; vertical-align:top;"| | | style="width: 50%; vertical-align:top;"| | ||
Revision as of 08:50, 7 December 2025
Supported platforms: ![]()
![]()
![]()
![]()
![]()
![]()
![]()
Available since: Gideros 2010-2011
Description
GTween is a light-weight instance oriented tween engine. This means that you instantiate tweens for specific purposes, and then reuse, update or discard them.
This is different than centralized tween engines where you "register" tweens with a global object. This provides a more familiar and useful interface for object oriented programmers.
GTween boasts a number of advanced features:
- frame and time based durations/positions which can be set per tween
- simple sequenced tweens using .nextTween
- pause and resume individual tweens or all tweens
- jump directly to the end or beginning of a tween with :toEnd() or :toBeginning()
- jump to any arbitrary point in the tween with :setPosition()
- complete, init, and change callbacks
- smart garbage collector interactions (prevents collection while active, allows collection if target is collected)
- easy to set up in a single line of code
- can repeat or reflect a tween a specified number of times
- deterministic, so setting a position on a tween will (almost) always result in predictable results
GTween (Gideros Tween) is more a Class than a plugin per se
To use the GTween library, add the following file to your project:
- Gtween.lua tip: right click and "Save Link As"
Note: GTween uses the Easing plugin so make sure to add it to your project Plugins
Example
--[[
Demonstration of GTween class
This code is MIT licensed, see http://www.opensource.org/licenses/mit-license.php
(C) 2010 - 2011 Gideros Mobile
]]
require "easing"
application:setBackgroundColor(0x626262)
local sprite = Bitmap.new(Texture.new("box.png"))
stage:addChild(sprite)
GTween.new(
sprite, 2,
{
x = 240,
},
{
delay = 0.2,
ease = easing.outBounce,
repeatCount = 2,
reflect = true,
}
)
See also
MethodsGTween.new creates a new GTween |
EventsConstants |