From e654344bc262c8393559e5cd535f440133fb2406 Mon Sep 17 00:00:00 2001 From: chai Date: Thu, 15 Nov 2018 21:44:02 +0800 Subject: =?UTF-8?q?*=E6=B8=B2=E6=9F=93=E7=9F=A9=E9=98=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lua/modules/graphics/je_lua_graphics.cpp | 48 ++++++++++++++++++++++++++++ src/lua/modules/time/je_lua_timer.cpp | 12 +++++-- 2 files changed, 57 insertions(+), 3 deletions(-) (limited to 'src/lua/modules') diff --git a/src/lua/modules/graphics/je_lua_graphics.cpp b/src/lua/modules/graphics/je_lua_graphics.cpp index 0a5394d..ce569d0 100644 --- a/src/lua/modules/graphics/je_lua_graphics.cpp +++ b/src/lua/modules/graphics/je_lua_graphics.cpp @@ -802,6 +802,47 @@ namespace JinEngine return 0; } + LUA_IMPLEMENT int l_clearMatrix(lua_State* L) + { + gl.clearMatrix(); + return 0; + } + + LUA_IMPLEMENT int l_pushMatrix(lua_State* L) + { + gl.push(); + return 0; + } + + LUA_IMPLEMENT int l_popMatrix(lua_State* L) + { + gl.pop(); + return 0; + } + + LUA_IMPLEMENT int l_scale(lua_State* L) + { + float sx = luax_checknumber(L, 1); + float sy = luax_checknumber(L, 2); + gl.scale(sx, sy); + return 0; + } + + LUA_IMPLEMENT int l_translate(lua_State* L) + { + float x = luax_checknumber(L, 1); + float y = luax_checknumber(L, 2); + gl.translate(x, y); + return 0; + } + + LUA_IMPLEMENT int l_rotate(lua_State* L) + { + float r = luax_checknumber(L, 1); + gl.rotate(r); + return 0; + } + LUA_EXPORT int luaopen_graphics(lua_State* L) { luaopen_Bitmap(L); @@ -861,6 +902,13 @@ namespace JinEngine /* font */ { "setFont", l_setFont }, { "unsetFont", l_unsetFont }, + /* transform */ + { "pushMatrix", l_pushMatrix }, + { "clearMatrix", l_clearMatrix }, + { "popMatrix", l_popMatrix }, + { "translate", l_translate }, + { "rotate", l_rotate }, + { "scale", l_scale }, { 0, 0 } }; diff --git a/src/lua/modules/time/je_lua_timer.cpp b/src/lua/modules/time/je_lua_timer.cpp index 9104a42..540f205 100644 --- a/src/lua/modules/time/je_lua_timer.cpp +++ b/src/lua/modules/time/je_lua_timer.cpp @@ -47,7 +47,9 @@ namespace JinEngine func->pushParam(i); Timer::Handler* handler = timer->every(s, timerCallback, func, finishCallback); Proxy* proxy = luax_newinstance(L, Jin_Lua_Handler); - proxy->bind(new Shared(handler, Jin_Lua_Handler)); + Shared* shrHandler = new Shared(handler, Jin_Lua_Handler); + shrHandler->retain(); + proxy->bind(shrHandler); return 1; } @@ -64,7 +66,9 @@ namespace JinEngine func->pushParam(i); Timer::Handler* handler = timer->after(s, timerCallback, func, finishCallback); Proxy* proxy = luax_newinstance(L, Jin_Lua_Handler); - proxy->bind(new Shared(handler, Jin_Lua_Handler)); + Shared* shrHandler = new Shared(handler, Jin_Lua_Handler); + shrHandler->retain(); + proxy->bind(shrHandler); return 1; } @@ -82,7 +86,9 @@ namespace JinEngine func->pushParam(i); Timer::Handler* handler = timer->repeat(s, count, timerCallback, func, finishCallback); Proxy* proxy = luax_newinstance(L, Jin_Lua_Handler); - proxy->bind(new Shared(handler, Jin_Lua_Handler)); + Shared* shrHandler = new Shared(handler, Jin_Lua_Handler); + shrHandler->retain(); + proxy->bind(shrHandler); return 1; } -- cgit v1.1-26-g67d0