Commits

Bart van Strien  committed 7391a1f

Add SpriteBatch:getImage (issue #321)

  • Participants
  • Parent commits 7246afe

Comments (0)

Files changed (5)

   * Added SpriteBatch:set.
   * Added new events system, with support for custom events and long event names.
   * Added sound attenuation by distance.
+  * Added SpriteBatch:getImage.
 
   * Fixed wrapping for single words.
   * Fixed tracebacks not showing filenames.

File src/modules/graphics/opengl/SpriteBatch.cpp

 		image->retain();
 	}
 
+	Image *SpriteBatch::getImage()
+	{
+		return image;
+	}
+
 	void SpriteBatch::setColor(const Color & color)
 	{
 		if (!this->color)

File src/modules/graphics/opengl/SpriteBatch.h

 		void unlock();
 
 		void setImage(Image * newimage);
+		Image *getImage();
 
 		/**
 		 * Set the current color for this SpriteBatch. The geometry added

File src/modules/graphics/opengl/wrap_SpriteBatch.cpp

 * 3. This notice may not be removed or altered from any source distribution.
 **/
 
+#include "Image.h"
 #include "wrap_SpriteBatch.h"
 
 namespace love
 		return 0;
 	}
 
+	int w_SpriteBatch_getImage(lua_State * L)
+	{
+		SpriteBatch * t = luax_checkspritebatch(L, 1);
+		Image * image = t->getImage();
+		image->retain();
+		luax_newtype(L, "Image", GRAPHICS_IMAGE_T, (void*)image);
+		return 1;
+	}
+
 	int w_SpriteBatch_setColor(lua_State * L)
 	{
 		SpriteBatch * t = luax_checkspritebatch(L, 1);
 		{ "bind", w_SpriteBatch_bind },
 		{ "unbind", w_SpriteBatch_unbind },
 		{ "setImage", w_SpriteBatch_setImage },
+		{ "getImage", w_SpriteBatch_getImage },
 		{ "setColor", w_SpriteBatch_setColor },
 		{ 0, 0 }
 	};

File src/modules/graphics/opengl/wrap_SpriteBatch.h

 	int w_SpriteBatch_lock(lua_State * L);
 	int w_SpriteBatch_unlock(lua_State * L);
 	int w_SpriteBatch_setImage(lua_State * L);
+	int w_SpriteBatch_getImage(lua_State * L);
 
 	extern "C" int luaopen_spritebatch(lua_State * L);