diff options
Diffstat (limited to 'src/lua/modules/graphics/je_lua_animation.cpp')
-rw-r--r-- | src/lua/modules/graphics/je_lua_animation.cpp | 36 |
1 files changed, 17 insertions, 19 deletions
diff --git a/src/lua/modules/graphics/je_lua_animation.cpp b/src/lua/modules/graphics/je_lua_animation.cpp index bdba10d..2bb635a 100644 --- a/src/lua/modules/graphics/je_lua_animation.cpp +++ b/src/lua/modules/graphics/je_lua_animation.cpp @@ -20,12 +20,10 @@ namespace JinEngine { const char* Jin_Lua_Animation = "Animation"; - typedef Shared<Animation>& SharedAnimation; - - LUA_IMPLEMENT inline SharedAnimation checkAnimation(lua_State* L) + LUA_IMPLEMENT inline Animation* checkAnimation(lua_State* L) { - LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Animation); - return luaObj->getShared<Animation>(); + LuaObject* luaObj = luax_checkobject(L, 1, Jin_Lua_Animation); + return luaObj->getObject<Animation>(); } LUA_IMPLEMENT int l_gc(lua_State* L) @@ -39,12 +37,12 @@ namespace JinEngine LUA_IMPLEMENT int l_addFrame(lua_State* L) { LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Animation); - SharedAnimation shrAnimation = luaObj->getShared<Animation>(); + Animation* animation = luaObj->getObject<Animation>(); LuaObject* luaSprite = (LuaObject*)luax_checktype(L, 2, Jin_Lua_Sprite); - Shared<Sprite>& shrSprite = luaSprite->getShared<Sprite>(); - shrAnimation->addFrame(shrSprite.getObject()); - int i = shrAnimation->getFrameCount() - 1; - luaObj->setDependency((int)AnimationDependency::DEP_SPRITES + i, &shrSprite); + Sprite* sprite = luaSprite->getObject<Sprite>(); + animation->addFrame(sprite); + int i = animation->getFrameCount() - 1; + luaObj->setDependency((int)AnimationDependency::DEP_SPRITES + i, luaSprite->getShared()); return 0; } @@ -52,7 +50,7 @@ namespace JinEngine LUA_IMPLEMENT int l_addFrames(lua_State* L) { LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Animation); - SharedAnimation shrAnimation = luaObj->getShared<Animation>(); + Animation* shrAnimation = luaObj->getObject<Animation>(); if (!luax_istable(L, 2)) { luax_typerror(L, 2, "sprites table"); @@ -63,17 +61,17 @@ namespace JinEngine { luax_rawgeti(L, 2, i); LuaObject* luaSprite = (LuaObject*)luax_checktype(L, -1, Jin_Lua_Sprite); - Shared<Sprite>& shrSprite = luaSprite->getShared<Sprite>(); - shrAnimation->addFrame(shrSprite.getObject()); + Sprite* sprite = luaSprite->getObject<Sprite>(); + shrAnimation->addFrame(sprite); int index = shrAnimation->getFrameCount() - 1; - luaObj->setDependency((int)AnimationDependency::DEP_SPRITES + index, &shrSprite); + luaObj->setDependency((int)AnimationDependency::DEP_SPRITES + index, luaSprite->getShared()); } return 0; } LUA_IMPLEMENT int l_isLoop(lua_State* L) { - SharedAnimation shrAnimation = checkAnimation(L); + Animation* shrAnimation = checkAnimation(L); bool loop = shrAnimation->isLoop(); luax_pushboolean(L, loop); return 1; @@ -81,7 +79,7 @@ namespace JinEngine LUA_IMPLEMENT int l_getSpeed(lua_State* L) { - SharedAnimation shrAnimation = checkAnimation(L); + Animation* shrAnimation = checkAnimation(L); float speed = shrAnimation->getSpeed(); luax_pushnumber(L, speed); return 1; @@ -90,16 +88,16 @@ namespace JinEngine LUA_IMPLEMENT int l_getFrame(lua_State* L) { LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Animation); - SharedAnimation shrAnimation = luaObj->getShared<Animation>(); + Animation* shrAnimation = luaObj->getObject<Animation>(); int i = luax_checkinteger(L, 2); - SharedBase* shrFrame = luaObj->getDependency((int)AnimationDependency::DEP_SPRITES + i); + Shared* shrFrame = luaObj->getDependency((int)AnimationDependency::DEP_SPRITES + i); luax_getobject(L, shrFrame); return 1; } LUA_IMPLEMENT int getFrameCount(lua_State* L) { - SharedAnimation shrAnimation = checkAnimation(L); + Animation* shrAnimation = checkAnimation(L); int n = shrAnimation->getFrameCount(); luax_pushinteger(L, n); return 1; |