diff options
Diffstat (limited to 'src/lua/modules/graphics/je_lua_animation.cpp')
-rw-r--r-- | src/lua/modules/graphics/je_lua_animation.cpp | 71 |
1 files changed, 71 insertions, 0 deletions
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<Animation>& SharedAnimation; + + LUA_IMPLEMENT inline SharedAnimation checkAnimation(lua_State* L) + { + Proxy* proxy = (Proxy*)luax_checktype(L, 1, Jin_Lua_Animation); + return proxy->getShared<Animation>(); + } + + 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<int> 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 |