Wednesday, 24 July 2013

How to zoom in an object and zoom back to normal state in Corona SDK

In Cocos2d you can easily scale an object within two values. For example, you can scale an object to 0.2, and can restore it to 1, whenever you need. But in Corona, if you scale to an object to a value of 0.2, and try and rescale to 1, it keeps it as 0.2. Because, in corona SDK, when you scale an object to a value other than 1, the system will take the new scaled value as the fullscale of the object. So, here we will teach you a simple technique to scale/zoom in and out an object in corona SDK.

1: Create a scaleFactor :

               local scaleFactor = 0.2;

2: When you want to zoom out, do :

               myObject:scale(scaleFactor ,scaleFactor )

3: When you want to zoom in, do :

              myObject:scale(1/scaleFactor ,1/scaleFactor )


No comments:

Post a Comment