From 84aea028f9955c9313fa14b62d39a3e8e80b84b7 Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 14 Nov 2018 08:12:17 +0800 Subject: =?UTF-8?q?*=E6=9B=B4=E6=96=B0sprite?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lua/modules/graphics/je_lua_graphics.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/lua/modules/graphics/je_lua_graphics.cpp') diff --git a/src/lua/modules/graphics/je_lua_graphics.cpp b/src/lua/modules/graphics/je_lua_graphics.cpp index 5255de7..d129e6a 100644 --- a/src/lua/modules/graphics/je_lua_graphics.cpp +++ b/src/lua/modules/graphics/je_lua_graphics.cpp @@ -5,6 +5,7 @@ #include "lua/modules/luax.h" #include "lua/modules/types.h" #include "lua/common/je_lua_common.h" +#include "je_lua_spritesheet.h" using namespace std; using namespace JinEngine; @@ -666,6 +667,27 @@ namespace JinEngine return 1; } + LUA_IMPLEMENT int l_newSpriteSheet(lua_State* L) + { + Proxy* pxyGraphic = nullptr; + if (luax_istype(L, 1, JIN_GRAPHICS_TEXTURE)) + pxyGraphic = (Proxy*)luax_checktype(L, 1, JIN_GRAPHICS_TEXTURE); + else if(luax_istype(L, 1, JIN_GRAPHICS_CANVAS)) + pxyGraphic = (Proxy*)luax_checktype(L, 1, JIN_GRAPHICS_CANVAS); + if (pxyGraphic != nullptr) + { + Proxy* pxySSheet = luax_newinstance(L, JIN_GRAPHICS_SPRITESHEET); + Graphic* graphic = pxyGraphic->getObject(); + Shared& shrSSheet = pxySSheet->getShared(); + Shared& shrGraphic = pxyGraphic->getShared(); + shrSSheet.setDependency(SpriteSheetDependency::DEP_GRAPHIC, &shrGraphic); + pxySSheet->bind(new Shared(new SpriteSheet(graphic), JIN_GRAPHICS_SPRITESHEET)); + return 1; + } + else + return 0; + } + /* newTextureFont(bitmap, text, color | cellw, cellh) */ LUA_IMPLEMENT int l_newTextureFont(lua_State* L) { @@ -775,6 +797,7 @@ namespace JinEngine { "newText", l_newText }, { "newTextureFont", l_newTextureFont }, { "newSprite", l_newSprite }, + { "newSpriteSheet", l_newSpriteSheet }, /* render */ { "setClearColor", l_setClearColor }, { "clear", l_clear }, -- cgit v1.1-26-g67d0