SKActionTimingModes are insufficient

Number:rdar://14140444 Date Originated:13-Jun-2013
Status:Open Resolved:No
Product:iPhone SDK Product Version:7.0
Classification:Enhancement Reproducible:Yes
Title: SKActionTimingModes are insufficient

The SKAction class from Sprite Kit allows you to specify a timing mode, using an enum with the following values: Linear, Ease In, Ease Out, Ease In + Out. 

Unfortunately, a lot of the common timing modes that are used in games are missing (bounce, elastic, etc). More importantly, there is no easy way to add your own timing modes.

This is an example of what I'd like to see. You define a block that takes a float and returns a float: 

  typedef float (^SKActionTimingFunction)(float t);

The value of t is always between 0 and 1 and describes how far along the animation is. The block returns a modified value of t that curves the timing. 

Some examples:

  SKActionTimingFunction SKActionTimingFunctionLinear = ^(float t) {
	return t;

  SKActionTimingFunction SKActionTimingFunctionQuadraticEaseIn = ^(float t) {
	return t * t;

  SKActionTimingFunction SKActionTimingFunctionQuadraticEaseOut = ^(float t) {
	return t * (2.0f - t);

  SKActionTimingFunction SKActionTimingFunctionQuadraticEaseInOut = ^(float t) {
	if (t < 0.5f) {
	  return 2.0f * t * t;
	} else {
	  const float f = t - 1.0f;
	  return 1.0f - 2.0f * f * f;

But beyond the standard ease in & out, it easily allows users of Sprite Kit to extend this with more interesting effects, such as:

  SKActionTimingFunction SKActionTimingFunctionBackEaseInOut = ^(float t) {
	const float s = 1.70158f;
	if (t < 0.5f) {
	  const float f = 2.0f * t;
	  return 0.5f * ((s + 1.0f) * f - s) * f * f;
	} else {
	  const float f = 2.0f * (1.0f - t);
	  return 1.0f - 0.5f * ((s + 1.0f) * f - s) * f * f;

These kinds of timing curves are available in many other gaming toolkits. Not having this kind of flexibility makes Sprite Kit a lot less useful. Users of Sprite Kit need to be able to supply their own timing functions.

Note: Core Animation allows you to specify a timing function using a bezier path and 4 control points. That would be useful but by itself it is not enough. Having a block that takes a t value between 0 and 1, and can do any custom transformation on that, is a must.


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!