diff options
author | chai <chaifix@163.com> | 2019-01-14 16:40:14 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2019-01-14 16:40:14 +0800 |
commit | 98c9825c49a1674f59eafb3253829ca7d5cac3c1 (patch) | |
tree | bdd2a6da72fc998ff884b011a2260dc72537c25f /src/libjin-lua/modules/graphics/je_lua_animation.cpp | |
parent | 8b00d67febf133e89f6a0bfabc41feed555dc4a9 (diff) |
*rename source file
Diffstat (limited to 'src/libjin-lua/modules/graphics/je_lua_animation.cpp')
-rw-r--r-- | src/libjin-lua/modules/graphics/je_lua_animation.cpp | 122 |
1 files changed, 0 insertions, 122 deletions
diff --git a/src/libjin-lua/modules/graphics/je_lua_animation.cpp b/src/libjin-lua/modules/graphics/je_lua_animation.cpp deleted file mode 100644 index 5cd3b1f..0000000 --- a/src/libjin-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 |