Wobble on touch

Hi all,

I’m hoping that someone can help with this.

I’ve been using gamesalad for some time, and have been toying with the idea of moving to corona as I personally feel that this platform will eventually enable me to develop more advanced and speed apps.

However, I’m calling out to the community to see if anyone can help me with the below while I try and figure out corona and the lua language.

Basically, I’m working on developing a simple book, eventually it will include games, loads of interactivity and games, however, to start with I’m simply trying to work out how to on touch to make an image wobble for 2 seconds.

So, the situation would be:

A screen with say 4 objects, you touch an object and that object you’ve touched shakes (or bounces) for a few seconds.

That’s it.

I’m taking the whole of the development in baby steps as I really want to learn and understand how corona works and understand lua.

Currently my knowledge of corona is very limited, I know how to add images to a scene and how to place them in certain areas, and that’s basically it, so any help would be really appreciated.

Previously I’ve been fortunate enough to have the luxury of gamesalad where I could could simple drag and drop, however I really want to learn corona and the next step is to work out how to make a wobble/judder/bounce action after a touch.

Thank you all for your help,
Cheers
Chris [import]uid: 43642 topic_id: 34305 reply_id: 334305[/import]

I found some code in a forum post or in the Community Code that shakes an image.

local function doShake(target)  
 local firstTran, secondTran, thirdTran  
  
 --Third Transition  
 thirdTran = function()  
 if target.shakeType == "Loop" or (target.shakeCount and target.shakeCount \> 0) then  
 if target.shakeCount and target.shakeCount \> 0 then  
 target.shakeCount = target.shakeCount - 1  
 end  
 transition.to(target, {transition = inOutExpo, time = 75, rotation = 0, onComplete = firstTran})  
 else  
 transition.to(target, {transition = inOutExpo, time = 75, rotation = 0})  
 timer.performWithDelay(2000, function()  
 transition.to(target.icon, {time = 500, alpha = 0})  
 end)  
 end  
 end  
  
 --Second Transition  
 secondTran = function()  
 transition.to(target, {transition = inOutExpo, time = 75, alpha = 1, rotation = -5, onComplete = thirdTran})  
 end  
  
 --First Transtion  
 firstTran = function()  
 transition.to(target, {transition = inOutExpo, time = 75, rotation = 5, onComplete = secondTran})  
 end  
  
 --Do the first transition  
 firstTran()  
end  

[import]uid: 199310 topic_id: 34305 reply_id: 136393[/import]

I found some code in a forum post or in the Community Code that shakes an image.

local function doShake(target)  
 local firstTran, secondTran, thirdTran  
  
 --Third Transition  
 thirdTran = function()  
 if target.shakeType == "Loop" or (target.shakeCount and target.shakeCount \> 0) then  
 if target.shakeCount and target.shakeCount \> 0 then  
 target.shakeCount = target.shakeCount - 1  
 end  
 transition.to(target, {transition = inOutExpo, time = 75, rotation = 0, onComplete = firstTran})  
 else  
 transition.to(target, {transition = inOutExpo, time = 75, rotation = 0})  
 timer.performWithDelay(2000, function()  
 transition.to(target.icon, {time = 500, alpha = 0})  
 end)  
 end  
 end  
  
 --Second Transition  
 secondTran = function()  
 transition.to(target, {transition = inOutExpo, time = 75, alpha = 1, rotation = -5, onComplete = thirdTran})  
 end  
  
 --First Transtion  
 firstTran = function()  
 transition.to(target, {transition = inOutExpo, time = 75, rotation = 5, onComplete = secondTran})  
 end  
  
 --Do the first transition  
 firstTran()  
end  

[import]uid: 199310 topic_id: 34305 reply_id: 136393[/import]