Heh, that’s cool! Didn’t follow this thread but I’m going to be writing my shake as easing from now on as well.
Antheor, this doesn’t work for more than one direction, you have to start each direction separately.
You could start one transistion for both x and y, but that’s probably not what you want. It will shake diagonally.
But it works for alpha and scaling.
I do
oscillate( f, a, 'x', time ) (obj) oscillate( f, a, 'y', time ) (obj)
I have indeed diagonally shake … but it’s cool enough 
What do you mean by ‘it works for alpha and scaling’ ?
Try this, it’s supereasy and works like a charm:
local square = display.newRect(768,1024,100,100) local shakeEasing = function(currentTime, duration, startValue, targetDelta) local shakeAmplitude = 100 -- maximum shake in pixels, at start of shake local timeFactor = (duration-currentTime)/duration -- goes from 1 to 0 during the transition local scaledShake =( timeFactor\*shakeAmplitude)+1 -- adding 1 prevents scaledShake from being less then 1 which would throw an error in the random code in the next line local randomShake = math.random(scaledShake) return startValue + randomShake - scaledShake\*0.5 -- the last part detracts half the possible max shake value so the shake is "symmetrical" instead of always being added at the same side end -- shakeEasing transition.to(square, {time = 1000, x = square.x, y = square.y, transition = shakeEasing})
Johannes, your solution is quite elegant. I tried to shake both ‘x’ and ‘y’ but passing ‘xy’ or ‘x,y’ does not work…
Heh, that’s cool! Didn’t follow this thread but I’m going to be writing my shake as easing from now on as well.
Antheor, this doesn’t work for more than one direction, you have to start each direction separately.
You could start one transistion for both x and y, but that’s probably not what you want. It will shake diagonally.
But it works for alpha and scaling.
I do
oscillate( f, a, 'x', time ) (obj) oscillate( f, a, 'y', time ) (obj)
I have indeed diagonally shake … but it’s cool enough 
What do you mean by ‘it works for alpha and scaling’ ?
Try this, it’s supereasy and works like a charm:
local square = display.newRect(768,1024,100,100) local shakeEasing = function(currentTime, duration, startValue, targetDelta) local shakeAmplitude = 100 -- maximum shake in pixels, at start of shake local timeFactor = (duration-currentTime)/duration -- goes from 1 to 0 during the transition local scaledShake =( timeFactor\*shakeAmplitude)+1 -- adding 1 prevents scaledShake from being less then 1 which would throw an error in the random code in the next line local randomShake = math.random(scaledShake) return startValue + randomShake - scaledShake\*0.5 -- the last part detracts half the possible max shake value so the shake is "symmetrical" instead of always being added at the same side end -- shakeEasing transition.to(square, {time = 1000, x = square.x, y = square.y, transition = shakeEasing})
I have a question regarding tweaking the existing Easing Functions, but it would have taken this thread off-topic so, I have asked it here:
http://forums.coronalabs.com/topic/56204-custom-easing-and-tweaking-existing-easing-functions/
I have a question regarding tweaking the existing Easing Functions, but it would have taken this thread off-topic so, I have asked it here:
http://forums.coronalabs.com/topic/56204-custom-easing-and-tweaking-existing-easing-functions/