aboutsummaryrefslogtreecommitdiff
path: root/src/lua/modules/graphics/je_lua_animation.cpp
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2018-12-20 18:34:50 +0800
committerchai <chaifix@163.com>2018-12-20 18:34:50 +0800
commitee8ef0433e36bf354a717bd4af679a0a5af2e6be (patch)
tree2fc748510200f8bc24928d1938300eecc0604deb /src/lua/modules/graphics/je_lua_animation.cpp
parent7ae40127f15f8f2cb963a7efeb018f7887ebc1ea (diff)
*修改文件结构
Diffstat (limited to 'src/lua/modules/graphics/je_lua_animation.cpp')
-rw-r--r--src/lua/modules/graphics/je_lua_animation.cpp122
1 files changed, 0 insertions, 122 deletions
diff --git a/src/lua/modules/graphics/je_lua_animation.cpp b/src/lua/modules/graphics/je_lua_animation.cpp
deleted file mode 100644
index 5cd3b1f..0000000
--- a/src/lua/modules/graphics/je_lua_animation.cpp
+++ /dev/null
@@ -1,122 +0,0 @@
-#include "libjin/jin.h"
-
-#include "common/je_lua_object.h"
-#include "common/je_lua_common.h"
-
-#include "je_lua_sprite.h"
-#include "je_lua_canvas.h"
-#include "je_lua_texture.h"
-#include "je_lua_shader.h"
-#include "je_lua_animation.h"
-
-using namespace JinEngine::Math;
-using namespace JinEngine::Graphics;
-using namespace JinEngine::Graphics::Shaders;
-using namespace JinEngine::Graphics::Animations;
-
-namespace JinEngine
-{
- namespace Lua
- {
- const char* Jin_Lua_Animation = "Animation";
-
- LUA_IMPLEMENT inline Animation* checkAnimation(lua_State* L)
- {
- LuaObject* luaObj = luax_checkobject(L, 1, Jin_Lua_Animation);
- return luaObj->getObject<Animation>();
- }
-
- LUA_IMPLEMENT int l_gc(lua_State* L)
- {
- LuaObject* p = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Animation);
- p->release();
- return 0;
- }
-
- // addFrame(frame)
- LUA_IMPLEMENT int l_addFrame(lua_State* L)
- {
- LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Animation);
- Animation* animation = luaObj->getObject<Animation>();
- LuaObject* luaSprite = (LuaObject*)luax_checktype(L, 2, Jin_Lua_Sprite);
- Sprite* sprite = luaSprite->getObject<Sprite>();
- animation->addFrame(sprite);
- int i = animation->getFrameCount() - 1;
- luaObj->setDependency((int)AnimationDependency::DEP_SPRITES + i, luaSprite);
- return 0;
- }
-
- // addFrames(frames table)
- LUA_IMPLEMENT int l_addFrames(lua_State* L)
- {
- LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Animation);
- Animation* shrAnimation = luaObj->getObject<Animation>();
- if (!luax_istable(L, 2))
- {
- luax_typerror(L, 2, "sprites table");
- return 1;
- }
- int n = luax_tableidxlen(L, 2);
- for (int i = 1; i <= n; ++i)
- {
- luax_rawgeti(L, 2, i);
- LuaObject* luaSprite = (LuaObject*)luax_checktype(L, -1, Jin_Lua_Sprite);
- Sprite* sprite = luaSprite->getObject<Sprite>();
- shrAnimation->addFrame(sprite);
- int index = shrAnimation->getFrameCount() - 1;
- luaObj->setDependency((int)AnimationDependency::DEP_SPRITES + index, luaSprite);
- }
- return 0;
- }
-
- LUA_IMPLEMENT int l_isLoop(lua_State* L)
- {
- Animation* shrAnimation = checkAnimation(L);
- bool loop = shrAnimation->isLoop();
- luax_pushboolean(L, loop);
- return 1;
- }
-
- LUA_IMPLEMENT int l_getSpeed(lua_State* L)
- {
- Animation* shrAnimation = checkAnimation(L);
- float speed = shrAnimation->getSpeed();
- luax_pushnumber(L, speed);
- return 1;
- }
-
- LUA_IMPLEMENT int l_getFrame(lua_State* L)
- {
- LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Animation);
- Animation* shrAnimation = luaObj->getObject<Animation>();
- int i = luax_checkinteger(L, 2);
- LuaObject* frame = luaObj->getDependency((int)AnimationDependency::DEP_SPRITES + i);
- luax_getobject(L, frame);
- return 1;
- }
-
- LUA_IMPLEMENT int getFrameCount(lua_State* L)
- {
- Animation* shrAnimation = checkAnimation(L);
- int n = shrAnimation->getFrameCount();
- luax_pushinteger(L, n);
- return 1;
- }
-
- LUA_EXPORT void luaopen_Animation(lua_State* L)
- {
- luaL_Reg methods[] = {
- { "__gc", l_gc },
- { "addFrame", l_addFrame },
- { "addFrames", l_addFrames },
- { "isLoop", l_isLoop },
- { "getSpeed", l_getSpeed },
- { "getFrameCount", getFrameCount },
- { "getFrame", l_getFrame },
- { 0, 0 }
- };
- luax_newtype(L, Jin_Lua_Animation, methods);
- }
-
- } // namespace Lua
-} // namespace JinEngine \ No newline at end of file