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
VTiledSprite Class Reference

Tiled Sprites display a regular texture in a tiled format, so instead of scaling it repeats. This is good for backgrounds and also works with sprite animation! More...

#include <VTiledSprite.h>

Inheritance diagram for VTiledSprite:
VSprite VObject VBase

Public Types

typedef VSprite VSUPERCLASS
 Used to call parent class functions when they are overrided in class.
 
- Public Types inherited from VSprite
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

 VTiledSprite (sf::Vector2f Position, const sf::String &Filename="")
 
 VTiledSprite (float x=0, float y=0, const sf::String &Filename="")
 
virtual VSpriteLoadGraphic (const sf::String &filename, bool animated=false, int width=0, int height=0, const sf::IntRect &rect=sf::IntRect()) override
 
virtual VSpriteLoadGraphicFromTexture (sf::Texture &texture, bool animated=false, int width=0, int height=0, const sf::IntRect &rect=sf::IntRect()) override
 
virtual VSpriteMakeGraphic (int width, int height, sf::Color color, float outline=0, sf::Color outlineColor=sf::Color::Transparent) override
 
virtual VSpriteMakeGraphicCircle (int radius, sf::Color color, float outline=0, sf::Color outlineColor=sf::Color::Transparent) override
 
virtual VSpriteMakeGraphicSided (int radius, int sides, sf::Color color, float outline=0, sf::Color outlineColor=sf::Color::Transparent)
 
virtual VSpriteMakeGraphicConvex (const std::vector< sf::Vector2f > &points, sf::Color color, float outline=0, sf::Color outlineColor=sf::Color::Transparent)
 
virtual void Destroy () override
 Destroys the sprite rendering data (and texture if disposable is set for true).
 
virtual void Draw (sf::RenderTarget &RenderTarget) override
 
- Public Member Functions inherited from VSprite
 VSprite (sf::Vector2f Position, const sf::String &Filename="")
 
 VSprite (float x=0, float y=0, const sf::String &filename="")
 
virtual void Update (float dt) 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 updateTransform () override
 Update the tranform.
 
virtual void updateFrame () override
 Update the current frame for animations.
 
- Protected Member Functions inherited from VSprite
void setSize (unsigned int texWidth, unsigned int texHeight, bool animated=false, int width=0, int height=0, int offsetX=0, int offsetY=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 VSprite
sf::RenderStates RenderState = sf::RenderStates::Default
 RenderState for the Sprite.
 
sf::Color Tint = sf::Color::White
 Colour Tint of the Sprite.
 
sf::Vector2f Origin
 Origin of the Sprite in pixels (for rotation).
 
sf::Vector2f Offset
 Offset of the graphic from the Position.
 
sf::Vector2f Scale
 Scale transform.
 
sf::Vector2u FrameSize
 The size of a frame, can be different from Size.
 
bool FlipX = false
 If true, the sprite is flipped horzontally.
 
bool FlipY = false
 If true, the sprite is flipped vertically.
 
VAnimationManager Animation
 The animation manager for this sprite. Use this to set up and control sprite animations.
 
- 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 VSprite
bool disposible = false
 If true, texture will be destroyed within VSprite. Important if texture isn't loaded from VContent.
 
sf::VertexArray vertexArray
 Sprite render infomation.
 

Detailed Description

Tiled Sprites display a regular texture in a tiled format, so instead of scaling it repeats. This is good for backgrounds and also works with sprite animation!

Constructor & Destructor Documentation

◆ VTiledSprite() [1/2]

VTiledSprite::VTiledSprite ( sf::Vector2f  Position,
const sf::String &  Filename = "" 
)
inline
Parameters
PositionPosition of the Sprite.
FilenameFile path and name of the texture for this sprite.

◆ VTiledSprite() [2/2]

VTiledSprite::VTiledSprite ( float  x = 0,
float  y = 0,
const sf::String &  Filename = "" 
)
inline
Parameters
xX Position of the Sprite.
yY Position of the Sprite.
FilenameFile path and name of the texture for this sprite.

Member Function Documentation

◆ Draw()

virtual void VTiledSprite::Draw ( sf::RenderTarget &  RenderTarget)
overridevirtual

Renders the sprite. Updates sprite transform and rendering info.

Parameters
RenderTargetThe game's sf::RenderTarget object to render data onto.

Reimplemented from VSprite.

◆ LoadGraphic()

virtual VSprite* VTiledSprite::LoadGraphic ( const sf::String &  filename,
bool  animated = false,
int  width = 0,
int  height = 0,
const sf::IntRect &  rect = sf::IntRect() 
)
overridevirtual

Load Graphic from filepath.

Parameters
filenamePath of texture file.
animatedSets if the graphic is part of an animation or not.
widthWidth of sprite, ignored if animated is false.
heightHeight of sprite, ignored if animated is false.
rectOnly use a certain area of the texture, whether you are animated or not. Default value assumes whole texture is used. (Ignored if VTiledSprite or VBackdrop)

Reimplemented from VSprite.

◆ LoadGraphicFromTexture()

virtual VSprite* VTiledSprite::LoadGraphicFromTexture ( sf::Texture &  texture,
bool  animated = false,
int  width = 0,
int  height = 0,
const sf::IntRect &  rect = sf::IntRect() 
)
overridevirtual

Load Graphic from an sf::Texture object.

Parameters
texturesf::Texture object.
animatedSets if the graphic is part of an animation or not.
widthWidth of sprite, ignored if animated is false.
heightHeight of sprite, ignored if animated is false.
rectOnly use a certain area of the texture, whether you are animated or not. Default value assumes whole texture is used. (Ignored if VTiledSprite or VBackdrop)

Reimplemented from VSprite.

◆ MakeGraphic()

virtual VSprite* VTiledSprite::MakeGraphic ( int  width,
int  height,
sf::Color  color,
float  outline = 0,
sf::Color  outlineColor = sf::Color::Transparent 
)
inlineoverridevirtual

Make sprite texture. (NOT USED FOR TILED SPRITE)

Parameters
widthWidth of sprite.
heightHeight of sprite.
colorFill Colour of sprite.
outlineOutline thickness.
outlineColorcolour of sprite outline.

Reimplemented from VSprite.

◆ MakeGraphicCircle()

virtual VSprite* VTiledSprite::MakeGraphicCircle ( int  radius,
sf::Color  color,
float  outline = 0,
sf::Color  outlineColor = sf::Color::Transparent 
)
inlineoverridevirtual

Make sprite texture a circle. (NOT USED FOR TILED SPRITE)

Parameters
radiusRadius of the circle.
colorFill Colour of sprite.
outlineOutline thickness.
outlineColorcolour of sprite outline.

Reimplemented from VSprite.

◆ MakeGraphicConvex()

virtual VSprite* VTiledSprite::MakeGraphicConvex ( const std::vector< sf::Vector2f > &  points,
sf::Color  color,
float  outline = 0,
sf::Color  outlineColor = sf::Color::Transparent 
)
inlinevirtual

Make sprite texture a convex shape. (NOT USED FOR TILED SPRITE)

Parameters
pointsList of points that make out the shape.
colorFill Colour of sprite.
outlineOutline thickness.
outlineColorcolour of sprite outline.

◆ MakeGraphicSided()

virtual VSprite* VTiledSprite::MakeGraphicSided ( int  radius,
int  sides,
sf::Color  color,
float  outline = 0,
sf::Color  outlineColor = sf::Color::Transparent 
)
inlinevirtual

Make sprite texture a multisided shape. (NOT USED FOR TILED SPRITE)

Parameters
radiusRadius of the circle.
sidesNumber of sides of the shape.
colorFill Colour of sprite.
outlineOutline thickness.
outlineColorcolour of sprite outline.

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