Added SpriteBatch:getColor

This commit is contained in:
Alex Szpakowski
2013-06-14 05:29:05 -03:00
parent 0f6980f82a
commit be33d17f89
4 changed files with 31 additions and 1 deletions
@@ -201,6 +201,11 @@ void SpriteBatch::setColor()
color = 0;
}
const Color *SpriteBatch::getColor() const
{
return color;
}
int SpriteBatch::getCount() const
{
return next;
@@ -86,6 +86,12 @@ public:
*/
void setColor();
/**
* Get the current color for this SpriteBatch. Returns NULL if no color is
* set.
**/
const Color *getColor() const;
/**
* Get the number of sprites currently in this SpriteBatch.
**/
@@ -197,6 +197,23 @@ int w_SpriteBatch_setColor(lua_State *L)
return 0;
}
int w_SpriteBatch_getColor(lua_State *L)
{
SpriteBatch *t = luax_checkspritebatch(L, 1);
const Color *color = t->getColor();
// getColor returns NULL if no color is set.
if (!color)
return 0;
lua_pushinteger(L, (lua_Integer) color->r);
lua_pushinteger(L, (lua_Integer) color->g);
lua_pushinteger(L, (lua_Integer) color->b);
lua_pushinteger(L, (lua_Integer) color->a);
return 4;
}
int w_SpriteBatch_getCount(lua_State *L)
{
SpriteBatch *t = luax_checkspritebatch(L, 1);
@@ -223,6 +240,7 @@ static const luaL_Reg functions[] =
{ "setImage", w_SpriteBatch_setImage },
{ "getImage", w_SpriteBatch_getImage },
{ "setColor", w_SpriteBatch_setColor },
{ "getColor", w_SpriteBatch_getColor },
{ "getCount", w_SpriteBatch_getCount },
{ "getBufferSize", w_SpriteBatch_getBufferSize },
{ 0, 0 }
@@ -33,7 +33,7 @@ namespace opengl
SpriteBatch *luax_checkspritebatch(lua_State *L, int idx);
int w_SpriteBatch_add(lua_State *L);
int w_SpriteBatch_addq(lua_State *L);
int w_SpriteBatch_addg(lua_State *L);
int w_SpriteBatch_set(lua_State *L);
int w_SpriteBatch_setg(lua_State *L);
int w_SpriteBatch_clear(lua_State *L);
@@ -42,6 +42,7 @@ int w_SpriteBatch_unbind(lua_State *L);
int w_SpriteBatch_setImage(lua_State *L);
int w_SpriteBatch_getImage(lua_State *L);
int w_SpriteBatch_setColor(lua_State *L);
int w_SpriteBatch_getColor(lua_State *L);
int w_SpriteBatch_getCount(lua_State *L);
int w_SpriteBatch_getBufferSize(lua_State *L);