mirror of
https://github.com/love2d/love.git
synced 2026-08-16 16:20:42 +02:00
Added ParticleSystem:emit(num) (issue #577)
This commit is contained in:
@@ -478,6 +478,20 @@ void ParticleSystem::reset()
|
||||
emitCounter = 0;
|
||||
}
|
||||
|
||||
void ParticleSystem::emit(int num)
|
||||
{
|
||||
if (!active)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < num; i++)
|
||||
{
|
||||
if (isFull())
|
||||
return;
|
||||
|
||||
add();
|
||||
}
|
||||
}
|
||||
|
||||
bool ParticleSystem::isActive() const
|
||||
{
|
||||
return active;
|
||||
|
||||
@@ -377,6 +377,12 @@ public:
|
||||
**/
|
||||
void reset();
|
||||
|
||||
/**
|
||||
* Instantly emits a number of particles.
|
||||
* @param num The number of particles to emit.
|
||||
**/
|
||||
void emit(int num);
|
||||
|
||||
/**
|
||||
* Returns whether the particle emitter is active.
|
||||
**/
|
||||
|
||||
@@ -452,6 +452,14 @@ int w_ParticleSystem_reset(lua_State *L)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int w_ParticleSystem_emit(lua_State *L)
|
||||
{
|
||||
ParticleSystem *t = luax_checkparticlesystem(L, 1);
|
||||
int num = luaL_checkint(L, 2);
|
||||
t->emit(num);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int w_ParticleSystem_isActive(lua_State *L)
|
||||
{
|
||||
ParticleSystem *t = luax_checkparticlesystem(L, 1);
|
||||
@@ -518,6 +526,7 @@ static const luaL_Reg functions[] =
|
||||
{ "stop", w_ParticleSystem_stop },
|
||||
{ "pause", w_ParticleSystem_pause },
|
||||
{ "reset", w_ParticleSystem_reset },
|
||||
{ "emit", w_ParticleSystem_emit },
|
||||
{ "isActive", w_ParticleSystem_isActive },
|
||||
{ "isEmpty", w_ParticleSystem_isEmpty },
|
||||
{ "isFull", w_ParticleSystem_isFull },
|
||||
|
||||
@@ -67,6 +67,7 @@ int w_ParticleSystem_start(lua_State *L);
|
||||
int w_ParticleSystem_stop(lua_State *L);
|
||||
int w_ParticleSystem_pause(lua_State *L);
|
||||
int w_ParticleSystem_reset(lua_State *L);
|
||||
int w_ParticleSystem_emit(lua_State *L);
|
||||
int w_ParticleSystem_isActive(lua_State *L);
|
||||
int w_ParticleSystem_isEmpty(lua_State *L);
|
||||
int w_ParticleSystem_isFull(lua_State *L);
|
||||
|
||||
Reference in New Issue
Block a user