diff options
author | chai <chaifix@163.com> | 2018-11-14 21:21:54 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2018-11-14 21:21:54 +0800 |
commit | 611d12bdd245dd43b7434661d3e24f2b435378cb (patch) | |
tree | 976904a325695f76680934c0d917ee664e1529d5 /src/lua/modules/graphics/je_lua_spritesheet.cpp | |
parent | 84aea028f9955c9313fa14b62d39a3e8e80b84b7 (diff) |
*更新渲染模块
Diffstat (limited to 'src/lua/modules/graphics/je_lua_spritesheet.cpp')
-rw-r--r-- | src/lua/modules/graphics/je_lua_spritesheet.cpp | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/src/lua/modules/graphics/je_lua_spritesheet.cpp b/src/lua/modules/graphics/je_lua_spritesheet.cpp new file mode 100644 index 0000000..7994237 --- /dev/null +++ b/src/lua/modules/graphics/je_lua_spritesheet.cpp @@ -0,0 +1,53 @@ +#include "lua/modules/luax.h" +#include "lua/modules/types.h" +#include "lua/common/je_lua_common.h" +#include "libjin/jin.h" +#include "je_lua_sprite.h" +#include "je_lua_spritesheet.h" + +using namespace JinEngine::Math; +using namespace JinEngine::Graphics; + +namespace JinEngine +{ + namespace Lua + { + + LUA_IMPLEMENT int l_gc(lua_State* L) + { + Proxy* pxySSheet = (Proxy*)luax_checktype(L, 1, JIN_GRAPHICS_SPRITESHEET); + pxySSheet->release(); + return 0; + } + + LUA_IMPLEMENT int l_newSprite(lua_State* L) + { + Proxy* pxySSheet = (Proxy*)luax_checktype(L, 1, JIN_GRAPHICS_SPRITESHEET); + Shared<SpriteSheet>& shrSSheet = pxySSheet->getShared<SpriteSheet>(); + SpriteSheet* sheet = pxySSheet->getObject<SpriteSheet>(); + Quad quad; + quad.x = luax_checkinteger(L, 2); + quad.y = luax_checkinteger(L, 3); + quad.w = luax_checkinteger(L, 4); + quad.h = luax_checkinteger(L, 5); + Sprite* spr = sheet->createSprite(quad); + Proxy* pxySprite = luax_newinstance(L, JIN_GRAPHICS_SPRITE); + Shared<Sprite>* shrSprite = new Shared<Sprite>(spr, JIN_GRAPHICS_SPRITE); + shrSprite->setDependency((int)SpriteDependency::DEP_SPRITESHEET, &shrSSheet); + pxySprite->bind(shrSprite); + return 1; + } + + LUA_EXPORT int luaopen_SpriteSheet(lua_State* L) + { + luaL_Reg methods[] = { + { "__gc", l_gc }, + { "newSprite", l_newSprite }, + { 0, 0 } + }; + luax_newtype(L, JIN_GRAPHICS_SPRITESHEET, methods); + return 0; + } + + } +}
\ No newline at end of file |