From a16ce94158c9cf22a19c0e73dfe2e992a8302af1 Mon Sep 17 00:00:00 2001 From: chai Date: Sat, 8 Dec 2018 22:05:31 +0800 Subject: =?UTF-8?q?*=E5=8E=BB=E9=99=A4shared=20template?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lua/modules/graphics/je_lua_animation.cpp | 36 +++++++++++++-------------- 1 file changed, 17 insertions(+), 19 deletions(-) (limited to 'src/lua/modules/graphics/je_lua_animation.cpp') 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& 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(); + LuaObject* luaObj = luax_checkobject(L, 1, Jin_Lua_Animation); + return luaObj->getObject(); } 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 = luaObj->getObject(); LuaObject* luaSprite = (LuaObject*)luax_checktype(L, 2, Jin_Lua_Sprite); - Shared& shrSprite = luaSprite->getShared(); - shrAnimation->addFrame(shrSprite.getObject()); - int i = shrAnimation->getFrameCount() - 1; - luaObj->setDependency((int)AnimationDependency::DEP_SPRITES + i, &shrSprite); + Sprite* sprite = luaSprite->getObject(); + 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* shrAnimation = luaObj->getObject(); 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& shrSprite = luaSprite->getShared(); - shrAnimation->addFrame(shrSprite.getObject()); + Sprite* sprite = luaSprite->getObject(); + 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* shrAnimation = luaObj->getObject(); 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; -- cgit v1.1-26-g67d0