Transition Using Corona In Crossplatform Mobile App

Introduction :
Everyone wants to add some wow effects on their application by different means. Using Animation is one of the way to add some visual effects to the app. In corona transition can be used to make animation.

Description :
Transition API in corona gives you the oppurtunity to give animation effect to any object. So lets an example. We will have circle object, to which we will add some transition which will appear as animation. In order to do so lets have a file called main.lua.

CODE BlOCK :

main.lua :
 
-- Display the background color
display.setDefault( "background" , 25, 25, 112 )

Above line will add a background color of your app screen where “25, 25, 112” is the rgb color code format.

-- Define circle object
local myCircle = display.newCircle( 200, 200, 50 )

Here we define a local object using display API provided by coronasdk which called its newCircle function to make a circle.
We have passes three parameters on display.newCircle where 1st and 2nd one defines the x and y cordinates of the circle and 3rd parameter describes the radius of the circle.

Now lets have some animation. Initially the circle is at (200,200) coordinates. So lets change the position to (300, 500) coordinate. To do so we have transition API which is capable to do animation.

-- Animation applied
transition.to( myCircle, { x = 300, y = 500, time = 6000 })

On above line we called “to” function of transition API to change the position of the circle object. Here the first parameter is the object upon which we want to apply animation. Than we have define a table which holds the parameter of that object that we want to change as animation and we can also assign the time that needs to take to animate.
So here we are changing the x and y position of the circle in 6000 miliseconds.

Summary :
So like this way we can apply different animation to an object. We can also add an callback function before and after animation and also we can make some delay to to start the transition.

NOTE : Have checked in Android devices.

150 150 Burnignorance | Where Minds Meet And Sparks Fly!