From 9474767c68c48eff2618df80433b0b81ebf529c6 Mon Sep 17 00:00:00 2001 From: chai Date: Tue, 20 Nov 2018 21:43:01 +0800 Subject: =?UTF-8?q?*=E5=8A=A8=E7=94=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lua/modules/graphics/je_lua_animation.cpp | 71 +++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 src/lua/modules/graphics/je_lua_animation.cpp (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 new file mode 100644 index 0000000..1db66f1 --- /dev/null +++ b/src/lua/modules/graphics/je_lua_animation.cpp @@ -0,0 +1,71 @@ +#include "lua/modules/luax.h" + +#include "lua/common/je_lua_common.h" +#include "libjin/jin.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"; + + typedef Shared& SharedAnimation; + + LUA_IMPLEMENT inline SharedAnimation checkAnimation(lua_State* L) + { + Proxy* proxy = (Proxy*)luax_checktype(L, 1, Jin_Lua_Animation); + return proxy->getShared(); + } + + LUA_IMPLEMENT int l_gc(lua_State* L) + { + Proxy* p = (Proxy*)luax_checktype(L, 1, Jin_Lua_Animation); + p->release(); + return 0; + } + + LUA_IMPLEMENT int l_render(lua_State* L) + { + SharedAnimation sprite = checkAnimation(L); + float x = luax_checknumber(L, 2); + float y = luax_checknumber(L, 3); + float sx = luax_checknumber(L, 4); + float sy = luax_checknumber(L, 5); + float r = luax_checknumber(L, 6); + sprite->render(x, y, sx, sy, r); + return 0; + } + + LUA_IMPLEMENT int l_getSize(lua_State* L) + { + SharedAnimation sprite = checkAnimation(L); + //Vector2 size = sprite->getSize(); + //luax_pushinteger(L, size.x); + //luax_pushinteger(L, size.y); + return 1; + } + + LUA_EXPORT void luaopen_Animation(lua_State* L) + { + luaL_Reg methods[] = { + { "__gc", l_gc }, + { "render", l_render }, + { "getSize", l_getSize }, + { 0, 0 } + }; + luax_newtype(L, Jin_Lua_Animation, methods); + } + + } // namespace Lua +} // namespace JinEngine \ No newline at end of file -- cgit v1.1-26-g67d0