Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Custom easing functions in transition.to
Started by david.hunt15 Oct 26 2014 06:19 PM

- - - - -
4 replies to this topic

Best Answer Vince_ , 29 October 2014 - 06:59 PM

http://www.webdevils.com/corona-more-easing-types/

Hey David, I'm on my phone so it's hard to go into detail but that's how the easingx.lua library is supposed to work.

Check out the link above for more information

[TOPIC CONTROLS]
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

david.hunt15

[GLOBAL: userInfoPane.html]
david.hunt15
  • Contributor

  • 143 posts
  • Corona SDK

Hi,

 

transistion.to is great and the out of the box easing function are great also..

 

However, out of the preset ones i can't quite get the effect I want. After reading the docs here:

 

http://docs.coronalabs.com/api/library/easing/index.html

 

it mentions the built in ones are based on Robert Penner's easing functions

 

I had a play on the function generator and came up with a couple that suit my needs better.

 

 http://www.timotheegroleau.com/Flash/experiments/easing_function_generator.htm

 

I had a play trying to get a custom one working but im not sure what my function needs to accept and return to get it to work.  

 

This is a function as generated from the link above:

function(t, b, c, d) {
	var ts=(t/=d)*t;
	var tc=ts*t;
	return b+c*(tc*ts + -5*ts*ts + 10*tc + -10*ts + 5*t);
}

so in corona speak I thought I could just do this:

-- approx conversion
local function myEasing(t, b, c, d) 
	local ts=(t/d)*t
	local tc=ts*t
	return b+c*(tc*ts + -5*ts*ts + 10*tc + -10*ts + 5*t)
end

transition.to( target, { transition=myEasing } )

Is there some documentation anywhere that i've missed? if not, has anybody got a working example so i can see how custom ones are created?

 

thanks!



[TOPIC: post.html]
#2

Vince_

[GLOBAL: userInfoPane.html]
Vince_
  • Contributor

  • 305 posts
  • Enterprise

I haven't played with custom easing myself but I did come across this library a while back. It might give you some insight on how custom easing is achieved.

 

easingx.lua



[TOPIC: post.html]
#3

david.hunt15

[GLOBAL: userInfoPane.html]
david.hunt15
  • Contributor

  • 143 posts
  • Corona SDK

Hi Vince,

 

I appreciate the reply but I don't think that is what im looking for.

 

I want to be able to use the built in corona transition.to  but just point the tranisition parameter to my own funciton.

 

I think this is a question for corona staff as they can see how the method for say "inBounce" looks and the parameters it accepts and returns.

 

Once i know that, i should be able to put my own formula in 



[TOPIC: post.html]
#4

Vince_

[GLOBAL: userInfoPane.html]
Vince_
  • Contributor

  • 305 posts
  • Enterprise

  Best Answer

http://www.webdevils.com/corona-more-easing-types/

Hey David, I'm on my phone so it's hard to go into detail but that's how the easingx.lua library is supposed to work.

Check out the link above for more information

[TOPIC: post.html]
#5

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 26,300 posts
  • Enterprise

why not put a print inside the easing function and make sure you are getting the values expected passed in.




[topic_controls]
[/topic_controls]