aboutsummaryrefslogtreecommitdiff
path: root/src/libjin-lua/modules/graphics/je_lua_animator.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/libjin-lua/modules/graphics/je_lua_animator.cpp')
-rw-r--r--src/libjin-lua/modules/graphics/je_lua_animator.cpp163
1 files changed, 0 insertions, 163 deletions
diff --git a/src/libjin-lua/modules/graphics/je_lua_animator.cpp b/src/libjin-lua/modules/graphics/je_lua_animator.cpp
deleted file mode 100644
index 94c61b5..0000000
--- a/src/libjin-lua/modules/graphics/je_lua_animator.cpp
+++ /dev/null
@@ -1,163 +0,0 @@
-#include "common/je_lua_object.h"
-#include "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_animator.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_Animator = "Animator";
-
- LUA_IMPLEMENT inline Animator* checkAnimator(lua_State* L)
- {
- LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Animator);
- return luaObj->getObject<Animator>();
- }
-
- LUA_IMPLEMENT int l_gc(lua_State* L)
- {
- LuaObject* obj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Animation);
- obj->release();
- return 0;
- }
-
- LUA_IMPLEMENT int l_update(lua_State* L)
- {
- Animator* animator = checkAnimator(L);
- float dt = luax_checknumber(L, 2);
- animator->update(dt);
- return 0;
- }
-
- LUA_IMPLEMENT int l_play(lua_State* L)
- {
- Animator* animator = checkAnimator(L);
- animator->play();
- return 0;
- }
-
- LUA_IMPLEMENT int l_pause(lua_State* L)
- {
- Animator* animator = checkAnimator(L);
- animator->pause();
- return 0;
- }
-
- LUA_IMPLEMENT int l_resume(lua_State* L)
- {
- Animator* animator = checkAnimator(L);
- animator->resume();
- return 0;
- }
-
- LUA_IMPLEMENT int l_rewind(lua_State* L)
- {
- Animator* animator = checkAnimator(L);
- animator->rewind();
- return 0;
- }
-
- LUA_IMPLEMENT int l_render(lua_State* L)
- {
- Animator* animator = checkAnimator(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);
- animator->render(x, y, sx, sy, r);
- return 0;
- }
-
- LUA_IMPLEMENT int l_setAnimation(lua_State* L)
- {
- LuaObject* luaAnimator = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Animator);
- Animator* animator = luaAnimator->getObject<Animator>();
- LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Animation);
- luaAnimator->setDependency((int)AnimatorDependency::DEP_ANIMATION, luaObj);
- animator->setAnimation(luaObj->getObject<Animation>());
- return 0;
- }
-
- LUA_IMPLEMENT int l_forceToFrame(lua_State* L)
- {
- Animator* shrAnimator = checkAnimator(L);
- int index = luax_checkinteger(L, 2);
- shrAnimator->forceToFrame(index);
- return 0;
- }
-
- LUA_IMPLEMENT int l_setSpeed(lua_State* L)
- {
- Animator* shrAnimator = checkAnimator(L);
- float fps = luax_checknumber(L, 2);
- shrAnimator->setSpeed(fps);
- return 0;
- }
-
- LUA_IMPLEMENT int l_setDefaultSpeed(lua_State* L)
- {
- Animator* shrAnimator = checkAnimator(L);
- shrAnimator->setDefaultSpeed();
- return 0;
- }
-
- LUA_IMPLEMENT int l_setLoop(lua_State* L)
- {
- Animator* shrAnimator = checkAnimator(L);
- bool loop = luax_checkbool(L, 2);
- shrAnimator->setLoop(loop);
- return 0;
- }
-
- LUA_IMPLEMENT int l_setDefaultLoop(lua_State* L)
- {
- Animator* shrAnimator = checkAnimator(L);
- shrAnimator->setDefaultLoop();
- return 0;
- }
-
- LUA_IMPLEMENT int l_getSpeed(lua_State* L)
- {
- Animator* shrAnimator = checkAnimator(L);
- float speed = shrAnimator->getSpeed();
- luax_pushnumber(L, speed);
- return 1;
- }
-
- LUA_EXPORT void luaopen_Animator(lua_State* L)
- {
- luaL_Reg methods[] = {
- { "__gc", l_gc },
- { "update", l_update },
- { "play", l_play },
- { "pause", l_pause },
- { "resume", l_resume },
- { "rewind", l_rewind },
- { "render", l_render },
- { "setAnimation", l_setAnimation },
- { "forceToFrame", l_forceToFrame },
- { "setSpeed", l_setSpeed },
- { "setDefaultSpeed", l_setDefaultSpeed },
- { "setLoop", l_setLoop },
- { "setDefaultLoop", l_setDefaultLoop },
- { "getSpeed", l_getSpeed },
- { 0, 0 }
- };
- luax_newtype(L, Jin_Lua_Animator, methods);
- }
-
- } // namespace Lua
-} // namespace JinEngine \ No newline at end of file