Parcourir la source

Implemented PhysicsCharacter::getAnimation().

Darryl Gough il y a 14 ans
Parent
commit
adbd61fb73
2 fichiers modifiés avec 15 ajouts et 1 suppressions
  1. 14 0
      gameplay/src/PhysicsCharacter.cpp
  2. 1 1
      gameplay/src/PhysicsCharacter.h

+ 14 - 0
gameplay/src/PhysicsCharacter.cpp

@@ -147,6 +147,20 @@ void PhysicsCharacter::addAnimation(const char* name, AnimationClip* clip, float
     _animations[name] = a;
 }
 
+AnimationClip* PhysicsCharacter::getAnimation(const char* name)
+{
+    if (name)
+    {
+        // Lookup the specified animation
+        std::map<const char*, CharacterAnimation>::iterator aitr = _animations.find(name);
+        if (aitr != _animations.end())
+        {
+            return aitr->second.clip;
+        }
+    }
+    return NULL;
+}
+
 void PhysicsCharacter::play(const char* name, AnimationFlags flags, float speed, unsigned int blendDuration, unsigned int layer)
 {
     CharacterAnimation* animation = NULL;

+ 1 - 1
gameplay/src/PhysicsCharacter.h

@@ -111,7 +111,7 @@ public:
      *
      * @return The specified animation clip.
      */
-    AnimationClip* getAnimation(const char* name) const;
+    AnimationClip* getAnimation(const char* name);
 
     /**
      * Plays the specified animation.