Added constructors with parameters for shapes, and default-constructed shapes are now always empty

This commit is contained in:
Laurent Gomila 2011-12-04 10:53:14 +01:00
parent 6034b80ddf
commit 44cc9bad84
8 changed files with 35 additions and 34 deletions

View file

@ -32,9 +32,9 @@
namespace sf
{
////////////////////////////////////////////////////////////
CircleShape::CircleShape() :
myRadius(10)
CircleShape::CircleShape(float radius)
{
SetRadius(radius);
}

View file

@ -31,13 +31,10 @@
namespace sf
{
////////////////////////////////////////////////////////////
ConvexShape::ConvexShape()
ConvexShape::ConvexShape() :
myPoints()
{
// Let's define a triangle by default... just so that it's not empty
SetPointsCount(3);
SetPoint(0, Vector2f(5, 0));
SetPoint(1, Vector2f(0, 10));
SetPoint(2, Vector2f(10, 10));
Update();
}

View file

@ -32,9 +32,9 @@
namespace sf
{
////////////////////////////////////////////////////////////
RectangleShape::RectangleShape() :
mySize(10, 10)
RectangleShape::RectangleShape(const Vector2f& size) :
{
SetSize(size);
}

View file

@ -33,10 +33,21 @@ namespace sf
{
////////////////////////////////////////////////////////////
StarShape::StarShape() :
myInnerRadius(10),
myOuterRadius(20),
myPointsCount(5)
myInnerRadius(0),
myOuterRadius(0),
myPointsCount(0)
{
Update();
}
////////////////////////////////////////////////////////////
StarShape::StarShape(float innerRadius, float outerRadius, unsigned int pointsCount) :
myInnerRadius(innerRadius),
myOuterRadius(outerRadius),
myPointsCount(pointsCount)
{
Update();
}