Vigilante Game Framework  1.0.0.8
A 2D/3D C++ Game Framework using SFML.
Public Types | Public Member Functions | Protected Member Functions | List of all members
VTextPath Class Reference

Special text object that renders text along a specific curve. More...

#include <VTextPath.h>

Inheritance diagram for VTextPath:
VText VObject VBase

Public Types

enum  PathCurveType : unsigned char { PATH_NONE, PATH_ANCHOR, PATH_BEZIER, NUM_PATH_CURVES }
 Used to set how the path should curve like. More...
 
typedef VText VSUPERCLASS
 Used to call parent class functions when they are overrided in class.
 
- Public Types inherited from VText
enum  VTextAlign : unsigned char { ALIGNLEFT = 0, ALIGNCENTER = 1, ALIGNCENTRE = 1, ALIGNRIGHT = 2 }
 Propertry for aligning the text within the text box.
 
enum  VTextWrap : unsigned char { WRAPNONE = 0, WRAPLETTER = 1, WRAPWORD = 2 }
 Property for the method of wrapping the text when it reaches the edge of the box.
 
typedef VObject VSUPERCLASS
 Used to call parent class functions when they are overrided in class.
 
- Public Types inherited from VObject
enum  SidesTouching : unsigned char {
  TOUCHNONE = 0, TOUCHLEFT = 1 << 0, TOUCHRIGHT = 1 << 1, TOUCHTOP = 1 << 2,
  TOUCHBOTTOM = 1 << 3, TOUCHWALL = TOUCHLEFT | TOUCHRIGHT, TOUCHALL = TOUCHLEFT | TOUCHRIGHT | TOUCHTOP | TOUCHBOTTOM
}
 Flags for which sides are allowed to check if being overlapped for collision purposes.
 
typedef VBase VSUPERCLASS
 Used to call parent class functions when they are overrided in class.
 

Public Member Functions

 VTextPath (float x=0, float y=0, float width=0, const sf::String &text="", int charSize=8)
 
virtual void Update (float dt) override
 
void AddPoint (const sf::Vector2f &point)
 
void SetPoints (const std::vector< sf::Vector2f > &points)
 
void UpdatePoint (unsigned int index, float x, float y)
 
void SetCurveType (PathCurveType curve)
 
PathCurveType GetCurveType ()
 
void SetPathOffset (float offset)
 
float GetPathOffset ()
 
- Public Member Functions inherited from VText
 VText (float x=0, float y=0, float width=0, const sf::String &text="", int charSize=8)
 
 VText (sf::Vector2f position, float width=0, const sf::String &text="", int charSize=8)
 
VTextSetFormat (const sf::String &filename, int charSize=8, sf::Color colour=sf::Color::White, VTextAlign alignment=VTextAlign::ALIGNLEFT, int style=sf::Text::Regular)
 
VTextSetFormat (sf::Font &fontData, int charSize=8, sf::Color colour=sf::Color::White, VTextAlign alignment=VTextAlign::ALIGNLEFT, int style=sf::Text::Regular)
 
void SetText (const sf::String &text)
 
void SetStyle (int style=sf::Text::Regular)
 
void SetFillTint (const sf::Color &colour)
 
void SetOutlineTint (const sf::Color &colour)
 
void SetFontSize (unsigned int size)
 
void SetWrap (const VTextWrap &wrapMode)
 
void SetLineSpaceModifier (int lineSpacing)
 
void SetAlignment (const VTextAlign &align)
 
void SetOutlineThickness (float thickness)
 
void SetOutlineOffset (const sf::Vector2f &offset)
 
void SetTextWidth (float width)
 
const sf::String & GetText ()
 
const int GetLength ()
 
unsigned int GetStyle ()
 
sf::Color const & GetFillTint ()
 
sf::Color const & GetOutlineTint ()
 
unsigned int GetFontSize ()
 
VTextWrap const & GetWrap ()
 
int GetLineSpaceModifier ()
 
VTextAlign const & GetAlignment ()
 
float GetOutlineThickness ()
 
sf::Vector2f const & GetOutlineOffset ()
 
float GetTextWidth ()
 
virtual void Destroy () override
 Destroys the text rendering data (and font if disposable is set for true).
 
virtual void Draw (sf::RenderTarget &RenderTarget) override
 
- Public Member Functions inherited from VObject
 VObject (sf::Vector2f position, sf::Vector2f size=sf::Vector2f())
 
 VObject (float x=0, float y=0, float width=0, float height=0)
 
void SetPositionAtCentre (float x, float y)
 
void SetPositionAtCentre (sf::Vector2f newPos)
 
bool IsSolid ()
 
virtual void Reset (sf::Vector2f newPos)
 
virtual void Reset (float x, float y)
 
virtual void Hurt (float damage)
 
- Public Member Functions inherited from VBase
virtual void Kill ()
 
virtual void Revive ()
 Revives the object by setting both alive and exists back to true.
 

Protected Member Functions

virtual void updateTextRender (const sf::String &text) override
 
- Protected Member Functions inherited from VText
virtual void updateTransform () override
 Update the transformable object.
 
void setDimensions ()
 Setup the string of text so that it fits within the text width.
 
void setCharacterRender (const sf::Glyph &glyph, float x, float y, sf::Color color, bool bold, float italic, int index, sf::VertexArray &vertices, float outline=0)
 
void setTextLine (float x, float y, sf::Color color, float offset, float thickness, int index, sf::VertexArray &vertices, float outline=0)
 
- Protected Member Functions inherited from VObject
virtual void updateMotion (float dt)
 

Additional Inherited Members

- Static Public Member Functions inherited from VObject
static bool separate (VObject *a, VObject *b)
 
static bool separateCircle (VObject *a, VObject *b)
 
static bool touchFlag (VObject *a, VObject *b)
 
static float computeVelocity (float v, float a, float d, float max, float dt)
 
static bool TestInView (const sf::View &renderTargetView, sf::View *defaultView, VObject *o, const sf::FloatRect &renderBox=sf::FloatRect())
 
- Static Public Member Functions inherited from VBase
static const wchar_t * VString (const char *fmt,...)
 
static void VLog (const char *fmt,...)
 
static void VLogError (const char *fmt,...)
 
static void VClearLog ()
 
- Public Attributes inherited from VText
sf::RenderStates RenderState = sf::RenderStates::Default
 RenderState for the vertex data.
 
sf::Vector2f Origin
 Origin point as percentage.
 
sf::Vector2f Scale = sf::Vector2f(1, 1)
 Scale transform.
 
- Public Attributes inherited from VObject
sf::Vector2f Position
 Position of the object.
 
sf::Vector2f Size
 Size of the object.
 
sf::Vector2f Last
 Position of the object on the previous frame.
 
float Radius = 0
 Radius amount for Circle Collisions.
 
float Angle = 0
 Angle of object.
 
float AngleVelocity = 0
 Velocity of rotation.
 
float AngleAcceleration = 0
 Acceleration of rotation.
 
float AngleDrag = 0
 Drag of rotation.
 
float AngleMax = 10000
 Maximum Velocity of rotation.
 
bool Moves = true
 If true, updates the objects position and angle.
 
sf::Vector2f Velocity
 Velocity of movement.
 
sf::Vector2f Acceleration
 Acceleration of movement.
 
sf::Vector2f Drag
 Drag of movement.
 
sf::Vector2f MaxVelocity
 Maximum velocity of movement.
 
sf::Vector2f ScrollFactor
 The amount the object will appear to move when the camera scrolls (1.0f = Scrolls as fast as the camera, 0.5f = Scrolls half as fast as the camera). Good for parallax scrolling.
 
float RotateFactor = 1
 The amount the object will appear to rotate when the camera rotates (1.0f = Rotates as fast as the camera, 0.5f = Rotates half as fast as the camera). Good for parallax scrolling.
 
float ZoomFactor = 1
 The amount the object will appear to scale when the camera zooms (1.0f = Scales as fast as the camera, 0.5f = Scales half as fast as the camera). Good for parallax scrolling.
 
float Elasticity = 0
 Bounciness of the object (0 assumes no bounce)
 
float Mass = 1
 Mass of object in comparison to other objects in world.
 
float Health = 100
 Standard health value (object dies if health is <= 0 when modified in the Hurt function)
 
bool Immovable = false
 If true, the object will not change its velocity on collision.
 
unsigned char Touching = SidesTouching::TOUCHNONE
 Which sides are currently touching (is reset on each Update call!)
 
unsigned char WasTouching = SidesTouching::TOUCHNONE
 Which sides on previous frame were touching (is reset on each Update call!)
 
unsigned char AllowCollisions = SidesTouching::TOUCHALL
 Which sides are allowed to check collisions for.
 
bool CollisionXDrag = true
 Useful for moving platforms.
 
- Public Attributes inherited from VBase
bool active = true
 Base can be updated using Update if true.
 
bool visible = true
 Base can be rendered using Draw if true.
 
bool alive = true
 Helper member that is mainly used filter out behaviours to objects which aren't alive in the scene.
 
bool exists = true
 Base can be updated and rendered if true, else it would no longer be treated as being part of the scene.
 
VType type = NONE
 Base object type, typically set in the constructor of an inherited object to specify what type it is.
 
uint32_t RefCount = 0
 Counts the amount of times the object is referenced in groups, ensures an object is only destroyed when no longer part of a single group.
 
- Static Public Attributes inherited from VObject
static float SeparateBias
 Adds to the maximum overlap distance between objects.
 
- Protected Attributes inherited from VText
sf::VertexArray vertices
 Vertex Data.
 
sf::Font * font = nullptr
 Font object.
 
sf::String text
 String of text that will be rendered.
 
int length = 0
 Current length of text.
 
unsigned int fontSize = 8
 Size of the text per character.
 
unsigned int style = sf::Text::Regular
 Flags for setting a text's display style.
 
VTextWrap wrap = WRAPWORD
 Text wrapping mode.
 
int lineSpaceModifier = 0
 Used for adjusting the distance between lines different to the default.
 
VTextAlign alignment = ALIGNLEFT
 Text alignment property.
 
float outlineThickness = 0.0f
 The thickness of the outline.
 
sf::Vector2f outlineOffset
 The position offset of the outline. Good to modify if you want to display the outline like a shadow.
 
bool dirty = false
 If true, the text vertex data is rebuilt for all the new properties.
 
bool disposible = false
 If true, the font is disposed by the Text object (in case the font isn't loaded from VContent).
 
sf::Vector2f origin
 Origin point for rotation.
 
sf::Color fillColour = sf::Color::White
 Main colour of the font.
 
sf::Color outlineColour = sf::Color::White
 Colour of the font outline.
 

Detailed Description

Special text object that renders text along a specific curve.

Member Enumeration Documentation

◆ PathCurveType

enum VTextPath::PathCurveType : unsigned char

Used to set how the path should curve like.

Enumerator
PATH_ANCHOR 

No path curve, straight lines between points.

PATH_BEZIER 

Path will curve by anchoring to an average of all points.

NUM_PATH_CURVES 

Path will curve as a bezier curve. The kind of bezier curve will depend on the amount of points set (if >= 4 then a 4 point, else a 3 point or linear interpolation.

Constructor & Destructor Documentation

◆ VTextPath()

VTextPath::VTextPath ( float  x = 0,
float  y = 0,
float  width = 0,
const sf::String &  text = "",
int  charSize = 8 
)
Parameters
xX position coordinate.
yY position coordinate.
widthThe width of the text area that will bound the text.
textThe string that the text object will display.
charSizeThe font size the text will be displayed at.

Member Function Documentation

◆ AddPoint()

void VTextPath::AddPoint ( const sf::Vector2f &  point)
Parameters
pointPoint to add to the path.

◆ GetCurveType()

PathCurveType VTextPath::GetCurveType ( )
inline
Returns
The current curve type set.

◆ GetPathOffset()

float VTextPath::GetPathOffset ( )
inline
Returns
Current path offset.

◆ SetCurveType()

void VTextPath::SetCurveType ( PathCurveType  curve)
inline
Parameters
curveThe type of curve that the points to follow.

◆ SetPathOffset()

void VTextPath::SetPathOffset ( float  offset)
inline
Parameters
offsetThe offset that the text should start rendering on the curve (wrapped to 1.0f). Text wraps along path.

◆ SetPoints()

void VTextPath::SetPoints ( const std::vector< sf::Vector2f > &  points)
Parameters
pointsA list of points to the path.

◆ Update()

virtual void VTextPath::Update ( float  dt)
overridevirtual

Updates text transform and rendering info.

Parameters
dtDelta Time between the previous and current frame.

Reimplemented from VObject.

◆ UpdatePoint()

void VTextPath::UpdatePoint ( unsigned int  index,
float  x,
float  y 
)

Update an existing point.

Parameters
indexThe index in the path array for the point you wish to update.
xThe X Coordinate of the new point.
yThe Y Coordinate of the new point.

◆ updateTextRender()

virtual void VTextPath::updateTextRender ( const sf::String &  text)
overrideprotectedvirtual

Update the vertex data to display text and outline.

Parameters
textThe string that will be used for displaying text.

Reimplemented from VText.


The documentation for this class was generated from the following file: