mirror of
https://github.com/love2d/love.git
synced 2026-08-16 16:20:42 +02:00
Rename ParticleSystem:setAreaSpread to setEmissionArea, and move the functionality from setAreaSpreadAngle/setAreSpreadIsRelativeDirection into setEmissionArea. Resolves issue #1311.
This commit is contained in:
@@ -196,14 +196,16 @@ int w_ParticleSystem_moveTo(lua_State *L)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int w_ParticleSystem_setAreaSpread(lua_State *L)
|
||||
int w_ParticleSystem_setEmissionArea(lua_State *L)
|
||||
{
|
||||
ParticleSystem *t = luax_checkparticlesystem(L, 1);
|
||||
|
||||
ParticleSystem::AreaSpreadDistribution distribution = ParticleSystem::DISTRIBUTION_NONE;
|
||||
float x = 0.f, y = 0.f;
|
||||
float angle = 0.0f;
|
||||
bool directionRelativeToCenter = false;
|
||||
|
||||
const char *str = lua_isnoneornil(L, 2) ? 0 : luaL_checkstring(L, 2);
|
||||
const char *str = lua_isnoneornil(L, 2) ? nullptr : luaL_checkstring(L, 2);
|
||||
if (str && !ParticleSystem::getConstant(str, distribution))
|
||||
return luax_enumerror(L, "particle distribution", ParticleSystem::getConstants(distribution), str);
|
||||
|
||||
@@ -213,55 +215,32 @@ int w_ParticleSystem_setAreaSpread(lua_State *L)
|
||||
y = (float) luaL_checknumber(L, 4);
|
||||
if (x < 0.0f || y < 0.0f)
|
||||
return luaL_error(L, "Invalid area spread parameters (must be >= 0)");
|
||||
|
||||
angle = (float) luaL_optnumber(L, 5, 0.0f);
|
||||
directionRelativeToCenter = luax_optboolean(L, 6, false);
|
||||
}
|
||||
|
||||
t->setAreaSpread(distribution, x, y);
|
||||
t->setEmissionArea(distribution, x, y, angle, directionRelativeToCenter);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int w_ParticleSystem_getAreaSpread(lua_State *L)
|
||||
int w_ParticleSystem_getEmissionArea(lua_State *L)
|
||||
{
|
||||
ParticleSystem *t = luax_checkparticlesystem(L, 1);
|
||||
ParticleSystem::AreaSpreadDistribution distribution = t-> getAreaSpreadDistribution();
|
||||
love::Vector2 p;
|
||||
float angle;
|
||||
bool directionRelativeToCenter;
|
||||
ParticleSystem::AreaSpreadDistribution distribution = t->getEmissionArea(p, angle, directionRelativeToCenter);
|
||||
const char *str;
|
||||
ParticleSystem::getConstant(distribution, str);
|
||||
const love::Vector2 &p = t->getAreaSpreadParameters();
|
||||
|
||||
lua_pushstring(L, str);
|
||||
lua_pushnumber(L, p.x);
|
||||
lua_pushnumber(L, p.y);
|
||||
lua_pushnumber(L, angle);
|
||||
luax_pushboolean(L, directionRelativeToCenter);
|
||||
|
||||
return 3;
|
||||
}
|
||||
|
||||
int w_ParticleSystem_setAreaSpreadAngle(lua_State *L)
|
||||
{
|
||||
ParticleSystem *t = luax_checkparticlesystem(L, 1);
|
||||
float arg1 = (float)luaL_checknumber(L, 2);
|
||||
t->setAreaSpreadAngle(arg1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int w_ParticleSystem_getAreaSpreadAngle(lua_State *L)
|
||||
{
|
||||
ParticleSystem *t = luax_checkparticlesystem(L, 1);
|
||||
lua_pushnumber(L, t->getAreaSpreadAngle());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int w_ParticleSystem_setAreaSpreadIsRelativeDirection(lua_State *L)
|
||||
{
|
||||
ParticleSystem *t = luax_checkparticlesystem(L, 1);
|
||||
bool arg1 = luax_checkboolean(L, 2);
|
||||
t->setAreaSpreadIsRelativeDirection(arg1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int w_ParticleSystem_getAreaSpreadIsRelativeDirection(lua_State *L)
|
||||
{
|
||||
ParticleSystem *t = luax_checkparticlesystem(L, 1);
|
||||
luax_pushboolean(L, t->getAreaSpreadIsRelativeDirection());
|
||||
return 1;
|
||||
return 5;
|
||||
}
|
||||
|
||||
int w_ParticleSystem_setDirection(lua_State *L)
|
||||
@@ -734,6 +713,52 @@ int w_ParticleSystem_update(lua_State *L)
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Deprecated functions.
|
||||
|
||||
int w_ParticleSystem_setAreaSpread(lua_State *L)
|
||||
{
|
||||
luax_markdeprecated(L, "ParticleSystem:setAreaSpread", API_METHOD, DEPRECATED_REPLACED, "ParticleSystem:setEmissionArea");
|
||||
|
||||
ParticleSystem *t = luax_checkparticlesystem(L, 1);
|
||||
|
||||
ParticleSystem::AreaSpreadDistribution distribution = ParticleSystem::DISTRIBUTION_NONE;
|
||||
float x = 0.f, y = 0.f;
|
||||
|
||||
const char *str = lua_isnoneornil(L, 2) ? 0 : luaL_checkstring(L, 2);
|
||||
if (str && !ParticleSystem::getConstant(str, distribution))
|
||||
return luax_enumerror(L, "particle distribution", ParticleSystem::getConstants(distribution), str);
|
||||
|
||||
if (distribution != ParticleSystem::DISTRIBUTION_NONE)
|
||||
{
|
||||
x = (float) luaL_checknumber(L, 3);
|
||||
y = (float) luaL_checknumber(L, 4);
|
||||
if (x < 0.0f || y < 0.0f)
|
||||
return luaL_error(L, "Invalid area spread parameters (must be >= 0)");
|
||||
}
|
||||
|
||||
t->setEmissionArea(distribution, x, y, 0.0f, false);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int w_ParticleSystem_getAreaSpread(lua_State *L)
|
||||
{
|
||||
luax_markdeprecated(L, "ParticleSystem:getAreaSpread", API_METHOD, DEPRECATED_REPLACED, "ParticleSystem:getEmissionArea");
|
||||
|
||||
ParticleSystem *t = luax_checkparticlesystem(L, 1);
|
||||
love::Vector2 p;
|
||||
float angle;
|
||||
bool unused;
|
||||
ParticleSystem::AreaSpreadDistribution distribution = t->getEmissionArea(p, angle, unused);
|
||||
const char *str;
|
||||
ParticleSystem::getConstant(distribution, str);
|
||||
|
||||
lua_pushstring(L, str);
|
||||
lua_pushnumber(L, p.x);
|
||||
lua_pushnumber(L, p.y);
|
||||
|
||||
return 3;
|
||||
}
|
||||
|
||||
static const luaL_Reg w_ParticleSystem_functions[] =
|
||||
{
|
||||
{ "clone", w_ParticleSystem_clone },
|
||||
@@ -752,12 +777,8 @@ static const luaL_Reg w_ParticleSystem_functions[] =
|
||||
{ "setPosition", w_ParticleSystem_setPosition },
|
||||
{ "getPosition", w_ParticleSystem_getPosition },
|
||||
{ "moveTo", w_ParticleSystem_moveTo },
|
||||
{ "setAreaSpread", w_ParticleSystem_setAreaSpread },
|
||||
{ "getAreaSpread", w_ParticleSystem_getAreaSpread },
|
||||
{ "setAreaSpreadAngle", w_ParticleSystem_setAreaSpreadAngle },
|
||||
{ "getAreaSpreadAngle", w_ParticleSystem_getAreaSpreadAngle },
|
||||
{ "setAreaSpreadIsRelativeDirection", w_ParticleSystem_setAreaSpreadIsRelativeDirection },
|
||||
{ "getAreaSpreadIsRelativeDirection", w_ParticleSystem_getAreaSpreadIsRelativeDirection },
|
||||
{ "setEmissionArea", w_ParticleSystem_setEmissionArea },
|
||||
{ "getEmissionArea", w_ParticleSystem_getEmissionArea },
|
||||
{ "setDirection", w_ParticleSystem_setDirection },
|
||||
{ "getDirection", w_ParticleSystem_getDirection },
|
||||
{ "setSpread", w_ParticleSystem_setSpread },
|
||||
@@ -800,6 +821,11 @@ static const luaL_Reg w_ParticleSystem_functions[] =
|
||||
{ "isPaused", w_ParticleSystem_isPaused },
|
||||
{ "isStopped", w_ParticleSystem_isStopped },
|
||||
{ "update", w_ParticleSystem_update },
|
||||
|
||||
// Deprecated.
|
||||
{ "setAreaSpread", w_ParticleSystem_setAreaSpread },
|
||||
{ "getAreaSpread", w_ParticleSystem_getAreaSpread },
|
||||
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user