mirror of
https://github.com/love2d/love.git
synced 2026-08-17 19:23:38 +02:00
Added CircleShape:get/setPoint.
This commit is contained in:
@@ -53,6 +53,19 @@ void CircleShape::setRadius(float r)
|
|||||||
shape->m_radius = Physics::scaleDown(r);
|
shape->m_radius = Physics::scaleDown(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CircleShape::getPoint(float &x_o, float &y_o) const
|
||||||
|
{
|
||||||
|
b2CircleShape *c = (b2CircleShape *) shape;
|
||||||
|
x_o = Physics::scaleUp(c->m_p.x);
|
||||||
|
y_o = Physics::scaleUp(c->m_p.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CircleShape::setPoint(float x, float y)
|
||||||
|
{
|
||||||
|
b2CircleShape *c = (b2CircleShape *) shape;
|
||||||
|
c->m_p = Physics::scaleDown(b2Vec2(x, y));
|
||||||
|
}
|
||||||
|
|
||||||
} // box2d
|
} // box2d
|
||||||
} // physics
|
} // physics
|
||||||
} // love
|
} // love
|
||||||
|
|||||||
@@ -58,10 +58,21 @@ public:
|
|||||||
float getRadius() const;
|
float getRadius() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the radius for the circle.
|
* Sets the radius of the circle.
|
||||||
**/
|
**/
|
||||||
void setRadius(float r);
|
void setRadius(float r);
|
||||||
};
|
|
||||||
|
/**
|
||||||
|
* Gets the position of the circle.
|
||||||
|
**/
|
||||||
|
void getPoint(float &x_o, float &y_o) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the position for the circle.
|
||||||
|
**/
|
||||||
|
void setPoint(float x, float y);
|
||||||
|
|
||||||
|
}; // CircleShape
|
||||||
|
|
||||||
} // box2d
|
} // box2d
|
||||||
} // physics
|
} // physics
|
||||||
|
|||||||
@@ -47,10 +47,29 @@ int w_CircleShape_setRadius(lua_State *L)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int w_CircleShape_getPoint(lua_State *L)
|
||||||
|
{
|
||||||
|
CircleShape *c = luax_checkcircleshape(L, 1);
|
||||||
|
float x, y;
|
||||||
|
c->getPoint(x, y);
|
||||||
|
lua_pushnumber(L, x);
|
||||||
|
lua_pushnumber(L, y);
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
int w_CircleShape_setPoint(lua_State *L)
|
||||||
|
{
|
||||||
|
CircleShape *c = luax_checkcircleshape(L, 1);
|
||||||
|
c->setPoint((float) luaL_checknumber(L, 2), (float) luaL_checknumber(L, 3));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static const luaL_Reg functions[] =
|
static const luaL_Reg functions[] =
|
||||||
{
|
{
|
||||||
{ "getRadius", w_CircleShape_getRadius },
|
{ "getRadius", w_CircleShape_getRadius },
|
||||||
{ "setRadius", w_CircleShape_setRadius },
|
{ "setRadius", w_CircleShape_setRadius },
|
||||||
|
{ "getPoint", w_CircleShape_getPoint },
|
||||||
|
{ "setPoint", w_CircleShape_setPoint },
|
||||||
// From Shape.
|
// From Shape.
|
||||||
{ "getType", w_Shape_getType },
|
{ "getType", w_Shape_getType },
|
||||||
{ "getRadius", w_Shape_getRadius },
|
{ "getRadius", w_Shape_getRadius },
|
||||||
|
|||||||
@@ -36,6 +36,8 @@ namespace box2d
|
|||||||
CircleShape *luax_checkcircleshape(lua_State *L, int idx);
|
CircleShape *luax_checkcircleshape(lua_State *L, int idx);
|
||||||
int w_CircleShape_getRadius(lua_State *L);
|
int w_CircleShape_getRadius(lua_State *L);
|
||||||
int w_CircleShape_setRadius(lua_State *L);
|
int w_CircleShape_setRadius(lua_State *L);
|
||||||
|
int w_CircleShape_getPoint(lua_State *L);
|
||||||
|
int w_CircleShape_setPoint(lua_State *L);
|
||||||
extern "C" int luaopen_circleshape(lua_State *L);
|
extern "C" int luaopen_circleshape(lua_State *L);
|
||||||
|
|
||||||
} // box2d
|
} // box2d
|
||||||
|
|||||||
Reference in New Issue
Block a user