writer class completed
This commit is contained in:
@@ -2,8 +2,9 @@
|
||||
#include "writer.h"
|
||||
|
||||
// Constructor
|
||||
Writer::Writer(std::string file, LTexture *texture, SDL_Renderer *renderer)
|
||||
Writer::Writer(Text *text)
|
||||
{
|
||||
mText = text;
|
||||
}
|
||||
|
||||
// Destructor
|
||||
@@ -14,16 +15,15 @@ Writer::~Writer()
|
||||
// Inicializador
|
||||
void Writer::init()
|
||||
{
|
||||
Text::init();
|
||||
mPosX = 0;
|
||||
mPosY = 0;
|
||||
mKerning = 0;
|
||||
mCaption = "";
|
||||
mWrittingSpeed = 0;
|
||||
mWrittingTimer = 0;
|
||||
mSpeed = 0;
|
||||
mTimer = 0;
|
||||
mIndex = 0;
|
||||
mLenght = 0;
|
||||
mWrittingCompleted = false;
|
||||
mCompleted = false;
|
||||
mEnabled = false;
|
||||
mEnabledTimer = 0;
|
||||
mId = -1;
|
||||
@@ -56,10 +56,10 @@ void Writer::setCaption(std::string text)
|
||||
}
|
||||
|
||||
// Establece el valor de la variable
|
||||
void Writer::setWrittingSpeed(Uint16 value)
|
||||
void Writer::setSpeed(Uint16 value)
|
||||
{
|
||||
mWrittingSpeed = value;
|
||||
mWrittingTimer = value;
|
||||
mSpeed = value;
|
||||
mTimer = value;
|
||||
}
|
||||
|
||||
// Establece el valor de la variable
|
||||
@@ -91,23 +91,23 @@ void Writer::update()
|
||||
{
|
||||
if (mEnabled)
|
||||
{
|
||||
if (mWrittingCompleted == false)
|
||||
if (mCompleted == false)
|
||||
{
|
||||
if (mWrittingTimer > 0)
|
||||
if (mTimer > 0)
|
||||
{
|
||||
mWrittingTimer--;
|
||||
mTimer--;
|
||||
}
|
||||
if (mWrittingTimer == 0)
|
||||
if (mTimer == 0)
|
||||
{
|
||||
mIndex++;
|
||||
mWrittingTimer = mWrittingSpeed;
|
||||
mTimer = mSpeed;
|
||||
}
|
||||
if (mIndex == mLenght)
|
||||
{
|
||||
mWrittingCompleted = true;
|
||||
mCompleted = true;
|
||||
}
|
||||
}
|
||||
if (mWrittingCompleted)
|
||||
if (mCompleted)
|
||||
{
|
||||
if (mEnabledTimer > 0)
|
||||
{
|
||||
@@ -133,14 +133,14 @@ void Writer::render()
|
||||
{
|
||||
if (mEnabled)
|
||||
{
|
||||
Text::write(mPosX, mPosY, mCaption, mKerning, mIndex);
|
||||
mText->write(mPosX, mPosY, mCaption, mKerning, mIndex);
|
||||
}
|
||||
}
|
||||
|
||||
// Centra la cadena de texto a un punto X
|
||||
void Writer::center(int x)
|
||||
{
|
||||
setPosX(x - (lenght(mCaption, mKerning) / 2));
|
||||
setPosX(x - (mText->lenght(mCaption, mKerning) / 2));
|
||||
}
|
||||
|
||||
// Establece el valor de la variable
|
||||
|
||||
Reference in New Issue
Block a user