Browse Source

set custom tween

dmuratshin 9 years ago
parent
commit
a342fa1640
2 changed files with 11 additions and 1 deletions
  1. 9 1
      oxygine/src/Tween.cpp
  2. 2 0
      oxygine/src/Tween.h

+ 9 - 1
oxygine/src/Tween.cpp

@@ -234,6 +234,8 @@ namespace oxygine
     }
     }
 
 
 
 
+	Tween::easeHandler _customEaseHandler = 0;
+
     float Tween::calcEase(EASE ease, float t)
     float Tween::calcEase(EASE ease, float t)
     {
     {
         const float s = 1.70158f;
         const float s = 1.70158f;
@@ -264,7 +266,8 @@ namespace oxygine
 				DEF_EASY_FROM_IN(Bounce, 1 - outBounce(1 - t));
 				DEF_EASY_FROM_IN(Bounce, 1 - outBounce(1 - t));
 
 
 			default:
 			default:
-				OX_ASSERT(!"unsupported ease");
+				t = _customEaseHandler(ease, t);
+				//OX_ASSERT(!"unsupported ease");
 				break;
 				break;
 		}
 		}
 
 
@@ -273,6 +276,11 @@ namespace oxygine
 		return t;
 		return t;
 	}
 	}
 
 
+	void  Tween::setCustomEaseHandler(easeHandler h)
+	{
+		_customEaseHandler = h;
+	}
+
 
 
 	std::string ease2String(Tween::EASE ease)
 	std::string ease2String(Tween::EASE ease)
 	{
 	{

+ 2 - 0
oxygine/src/Tween.h

@@ -148,6 +148,8 @@ namespace oxygine
         void update(Actor& actor, const UpdateState& us);
         void update(Actor& actor, const UpdateState& us);
 
 
         static float calcEase(EASE ease, float v);
         static float calcEase(EASE ease, float v);
+		typedef float (*easeHandler)(EASE ease, float v);
+		static void  setCustomEaseHandler(easeHandler);
 
 
         /**set callback when tween done. Doesn't allocate memory. faster than addDoneCallback*/
         /**set callback when tween done. Doesn't allocate memory. faster than addDoneCallback*/
         void setDoneCallback(const EventCallback& cb);
         void setDoneCallback(const EventCallback& cb);