Browse Source

Add animation Lua API.

Aster Jian 11 years ago
parent
commit
9a9b79fd8e

+ 10 - 0
Source/Engine/LuaScript/pkgs/Scene/Animatable.pkg

@@ -2,4 +2,14 @@ $#include "Animatable.h"
 
 
 class Animatable : Serializable
 class Animatable : Serializable
 {
 {
+    void SetAnimationEnabled(bool enable);
+    void SetObjectAnimation(ObjectAnimation* objectAnimation);
+    void SetAttributeAnimation(const String& name, AttributeAnimation* attributeAnimation);
+
+    bool GetAnimationEnabled() const;
+    const ObjectAnimation* GetObjectAnimation() const;
+    const AttributeAnimation* GetAttributeAnimation(const String& name) const;
+    
+    tolua_property__get_set bool animationEnabled;
+    tolua_property__get_set ObjectAnimation* objectAnimation;
 };
 };

+ 39 - 0
Source/Engine/LuaScript/pkgs/Scene/AttributeAnimation.pkg

@@ -0,0 +1,39 @@
+$#include "AttributeAnimation.h"
+
+enum CycleMode
+{
+    CM_LOOP = 0,
+    CM_CLAMP,
+    CM_PINGPONG,
+};
+
+class AttributeAnimation : public Resource
+{
+    AttributeAnimation();
+    virtual ~AttributeAnimation();
+    
+    void SetCycleMode(CycleMode cycleMode);
+    void SetValueType(VariantType valueType);
+    bool SetKeyFrame(float time, const Variant& value);
+    void SetEventFrame(float time, const StringHash& eventType, const VariantMap& eventData = VariantMap());
+    
+    CycleMode GetCycleMode() const;
+    VariantType GetValueType() const;
+
+    tolua_property__get_set CycleMode cycleMode;
+    tolua_property__get_set VariantType valueType;
+};
+
+${
+#define TOLUA_DISABLE_tolua_SceneLuaAPI_AttributeAnimation_new00
+static int tolua_SceneLuaAPI_AttributeAnimation_new00(lua_State* tolua_S)
+{
+    return ToluaNewObject<AttributeAnimation>(tolua_S);
+}
+
+#define TOLUA_DISABLE_tolua_SceneLuaAPI_AttributeAnimation_new00_local
+static int tolua_SceneLuaAPI_AttributeAnimation_new00_local(lua_State* tolua_S)
+{
+    return ToluaNewObjectGC<AttributeAnimation>(tolua_S);
+}
+$}

+ 25 - 0
Source/Engine/LuaScript/pkgs/Scene/ObjectAnimation.pkg

@@ -0,0 +1,25 @@
+$#include "ObjectAnimation.h"
+
+class ObjectAnimation : Resource
+{
+    ObjectAnimation();
+    virtual ~ObjectAnimation();
+    
+    void AddAttributeAnimation(const String name, AttributeAnimation* attributeAnimation);
+    void RemoveAttributeAnimation(const String name);
+    void RemoveAttributeAnimation(AttributeAnimation* attributeAnimation);
+};
+
+${
+#define TOLUA_DISABLE_tolua_SceneLuaAPI_ObjectAnimation_new00
+static int tolua_SceneLuaAPI_ObjectAnimation_new00(lua_State* tolua_S)
+{
+    return ToluaNewObject<ObjectAnimation>(tolua_S);
+}
+
+#define TOLUA_DISABLE_tolua_SceneLuaAPI_ObjectAnimation_new00_local
+static int tolua_SceneLuaAPI_ObjectAnimation_new00_local(lua_State* tolua_S)
+{
+    return ToluaNewObjectGC<ObjectAnimation>(tolua_S);
+}
+$}

+ 2 - 0
Source/Engine/LuaScript/pkgs/SceneLuaAPI.pkg

@@ -1,3 +1,5 @@
+$pfile "Scene/AttributeAnimation.pkg"
+$pfile "Scene/ObjectAnimation.pkg"
 $pfile "Scene/Serializable.pkg"
 $pfile "Scene/Serializable.pkg"
 $pfile "Scene/Animatable.pkg"
 $pfile "Scene/Animatable.pkg"
 $pfile "Scene/Component.pkg"
 $pfile "Scene/Component.pkg"