Transitions

In this chapter, we'll be touching base with transition.to() and transition.from():

For example:

_W = display.contentWidth
_H = display.contentHeight

local square = display.newRect( 0, 0, 100, 100 )
square:setFillColor( 1, 1, 1 )
square.x = _W/2; square.y = _H/2

local square2 = display.newRect( 0, 0, 50, 50 )
square2:setFillColor( 1, 1, 1 )
square2.x = _W/2; square2.y = _H/2

transition.to( square, { time=1500, x=250, y=400 } )
transition.from( square2, { time=1500, x=275, y=0 } )

The preceding example shows how two display objects transition throughout the space on a device screen. From its current position, the square display object will move to a new location of x = 250 and y = 400 in 1500 milliseconds. The square2 display object will transition from x = 275 and y = 0 to its initial location in 1500 milliseconds.