فهرست منبع

Merge pull request #100 from blackberry-gaming/next-kcunney

Updates to Animation
Chris Culy 14 سال پیش
والد
کامیت
3190df38f1

+ 10 - 11
gameplay/src/AnimationClip.cpp

@@ -441,6 +441,16 @@ bool AnimationClip::update(unsigned long elapsedTime)
     if (!_isPlaying)
     {
         onEnd();
+        // Notify end listeners if any.
+        if (_endListeners)
+        {
+            std::vector<Listener*>::iterator listener = _endListeners->begin();
+            while (listener != _endListeners->end())
+            {
+                (*listener)->animationEvent(this, Listener::END);
+                listener++;
+            }
+        }
     }
 
     return !_isPlaying;
@@ -494,17 +504,6 @@ void AnimationClip::onEnd()
 
     _blendWeight = 1.0f;
     _timeStarted = 0;
-
-    // Notify end listeners if any.
-    if (_endListeners)
-    {
-        std::vector<Listener*>::iterator listener = _endListeners->begin();
-        while (listener != _endListeners->end())
-        {
-            (*listener)->animationEvent(this, Listener::END);
-            listener++;
-        }
-    }
 }
 
 }

+ 5 - 2
gameplay/src/AnimationController.cpp

@@ -7,7 +7,7 @@ namespace gameplay
 {
 
 AnimationController::AnimationController()
-    : _state(IDLE), _animations(NULL)
+    : _state(STOPPED), _animations(NULL)
 {
 }
 
@@ -66,6 +66,7 @@ Animation* AnimationController::createAnimationFromTo(const char* id, AnimationT
 
     Animation* animation = createAnimation(id, target, propertyId, 2, keyTimes, keyValues, type);
 
+    SAFE_DELETE_ARRAY(keyValues);
     SAFE_DELETE_ARRAY(keyTimes);
     
     return animation;
@@ -85,6 +86,7 @@ Animation* AnimationController::createAnimationFromBy(const char* id, AnimationT
 
     Animation* animation = createAnimation(id, target, propertyId, 2, keyTimes, keyValues, type);
 
+    SAFE_DELETE_ARRAY(keyValues);
     SAFE_DELETE_ARRAY(keyTimes);
 
     return animation;
@@ -112,6 +114,7 @@ void AnimationController::stopAllAnimations()
         clip->_isPlaying = false;
         clip->onEnd();
         SAFE_RELEASE(clip);
+        clipIter++;
     }
     _runningClips.clear();
 
@@ -269,7 +272,7 @@ void AnimationController::initialize()
 void AnimationController::finalize()
 {
     stopAllAnimations();
-    _state = PAUSED;
+    _state = STOPPED;
 }
 
 void AnimationController::resume()

+ 2 - 1
gameplay/src/AnimationController.h

@@ -117,7 +117,8 @@ private:
     {
         RUNNING,
         IDLE,
-        PAUSED
+        PAUSED,
+        STOPPED
     };
 
     /**

+ 7 - 0
gameplay/src/Transform.cpp

@@ -551,6 +551,7 @@ unsigned int Transform::getAnimationPropertyComponentCount(int propertyId) const
 {
     switch (propertyId)
     {
+        case ANIMATE_SCALE_UNIT:
         case ANIMATE_SCALE_X:
         case ANIMATE_SCALE_Y:
         case ANIMATE_SCALE_Z:
@@ -576,6 +577,9 @@ void Transform::getAnimationPropertyValue(int propertyId, AnimationValue* value)
 {
     switch (propertyId)
     {
+        case ANIMATE_SCALE_UNIT:
+            value->setFloat(0, _scale.x);
+            break;
         case ANIMATE_SCALE:
             value->setFloat(0, _scale.x);
             value->setFloat(1, _scale.y);
@@ -640,6 +644,9 @@ void Transform::setAnimationPropertyValue(int propertyId, AnimationValue* value)
 {
     switch (propertyId)
     {
+        case ANIMATE_SCALE_UNIT:
+            setScale(value->getFloat(0));
+            break;
         case ANIMATE_SCALE:
             setScale(value->getFloat(0), value->getFloat(1), value->getFloat(2));
             break;

+ 5 - 0
gameplay/src/Transform.h

@@ -33,6 +33,11 @@ public:
     /**
      * Scale animation property. Data=sx,sy,sz
      */
+    static const int ANIMATE_SCALE_UNIT = 0;
+
+    /**
+     * Scale animation property. Data=scale
+     */
     static const int ANIMATE_SCALE = 1;
 
     /**