Game Development Reference
In-Depth Information
On the other hand, if we use transition.to , theObject is transitioned from the current settings to
the settings that we specify in the transition. This is also the reason that this transition is used more
often than the transition.from .
Both of the transition functions return a transition handle that we can capture. This handle can be
used with the transition.cancel function to cancel the transition.
Tip One good way to manage the transition handle and transitions without creating additional variables
is to save the transition into the object itself. This way, you can cancel the transition without having to
look very far before you can delete the object especially if the object is halfway through the transition.
theText.x = theText.contentWidth
theText.trans = transition.to(
theText,{time=8000, x=-theText.contentWidth})
--
local ball = display.newCircle ( 160, 480, 50 )
ball:setFillColor(255,255,0)
ball.alpha = 0.5
ball:scale(0.5,0.5)
--
transition.to (ball, {time = 2000, y = 80, onComplete=function()
transition.cancel(theText.trans)
end} )
Notice that the moment the sun reaches the top of the screen, the transition stops the text-scrolling
transition by canceling it.
There is another parameter that you can pass to these transition functions, and that is delta . This is
a Boolean value that is either true or false . The default value is false , and it specifies whether the
values passed are absolute values or relative to current values.
The transitions do not have to be linear (i.e., uniform in the steps) while sliding the text off the screen;
for example, you can give your transition the effect of acceleration or deceleration as it reaches its
target position. This type of acceleration and deceleration behavior is knows as easing in and easing
out , respectively. There are a few easing options that are available with Corona SDK.
Search WWH ::




Custom Search