aboutsummaryrefslogtreecommitdiff
path: root/src/lua/modules/graphics/je_lua_graphics.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/lua/modules/graphics/je_lua_graphics.cpp')
-rw-r--r--src/lua/modules/graphics/je_lua_graphics.cpp23
1 files changed, 23 insertions, 0 deletions
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<Graphic>();
+ Shared<SpriteSheet>& shrSSheet = pxySSheet->getShared<SpriteSheet>();
+ Shared<Graphic>& shrGraphic = pxyGraphic->getShared<Graphic>();
+ shrSSheet.setDependency(SpriteSheetDependency::DEP_GRAPHIC, &shrGraphic);
+ pxySSheet->bind(new Shared<SpriteSheet>(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 },