mirror of
https://github.com/love2d/love.git
synced 2026-08-17 19:23:38 +02:00
Merged.
This commit is contained in:
@@ -118,7 +118,7 @@ namespace box2d
|
|||||||
|
|
||||||
void Body::applyImpulse(float jx, float jy)
|
void Body::applyImpulse(float jx, float jy)
|
||||||
{
|
{
|
||||||
body->ApplyImpulse(b2Vec2(jx, jy), world->scaleDown(body->GetWorldCenter()));
|
body->ApplyImpulse(b2Vec2(jx, jy), body->GetWorldCenter());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Body::applyImpulse(float jx, float jy, float rx, float ry)
|
void Body::applyImpulse(float jx, float jy, float rx, float ry)
|
||||||
@@ -138,7 +138,7 @@ namespace box2d
|
|||||||
|
|
||||||
void Body::applyForce(float fx, float fy)
|
void Body::applyForce(float fx, float fy)
|
||||||
{
|
{
|
||||||
body->ApplyForce(b2Vec2(fx, fy), world->scaleDown(body->GetWorldCenter()));
|
body->ApplyForce(b2Vec2(fx, fy), body->GetWorldCenter());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Body::setX(float x)
|
void Body::setX(float x)
|
||||||
|
|||||||
@@ -140,9 +140,22 @@ namespace box2d
|
|||||||
Body * t = luax_checkbody(L, 1);
|
Body * t = luax_checkbody(L, 1);
|
||||||
float jx = (float)luaL_checknumber(L, 2);
|
float jx = (float)luaL_checknumber(L, 2);
|
||||||
float jy = (float)luaL_checknumber(L, 3);
|
float jy = (float)luaL_checknumber(L, 3);
|
||||||
float rx = (float)luaL_optnumber(L, 4, 0);
|
|
||||||
float ry = (float)luaL_optnumber(L, 5, 0);
|
if(lua_gettop(L) == 3)
|
||||||
t->applyImpulse(jx, jy, rx, ry);
|
{
|
||||||
|
t->applyImpulse(jx, jy);
|
||||||
|
}
|
||||||
|
else if(lua_gettop(L) == 5)
|
||||||
|
{
|
||||||
|
float rx = (float)luaL_checknumber(L, 4);
|
||||||
|
float ry = (float)luaL_checknumber(L, 5);
|
||||||
|
t->applyImpulse(jx, jy, rx, ry);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return luaL_error(L, "Wrong number of parameters.");
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,9 +172,23 @@ namespace box2d
|
|||||||
Body * t = luax_checkbody(L, 1);
|
Body * t = luax_checkbody(L, 1);
|
||||||
float fx = (float)luaL_checknumber(L, 2);
|
float fx = (float)luaL_checknumber(L, 2);
|
||||||
float fy = (float)luaL_checknumber(L, 3);
|
float fy = (float)luaL_checknumber(L, 3);
|
||||||
float rx = (float)luaL_optnumber(L, 4, 0);
|
|
||||||
float ry = (float)luaL_optnumber(L, 5, 0);
|
|
||||||
t->applyForce(fx, fy, rx, ry);
|
if(lua_gettop(L) == 3)
|
||||||
|
{
|
||||||
|
t->applyForce(fx, fy);
|
||||||
|
}
|
||||||
|
else if(lua_gettop(L) == 5)
|
||||||
|
{
|
||||||
|
float rx = (float)luaL_checknumber(L, 4);
|
||||||
|
float ry = (float)luaL_checknumber(L, 5);
|
||||||
|
t->applyForce(fx, fy, rx, ry);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return luaL_error(L, "Wrong number of parameters.");
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user