update text.cpp
This commit is contained in:
@@ -1,15 +1,14 @@
|
|||||||
#ifdef _WIN64
|
#ifdef _WIN64
|
||||||
#include "C:\mingw_dev_lib\include\SDL2\SDL.h"
|
#include "C:\Program Files\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\include\SDL2\SDL.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include "C:\mingw_dev_lib\include\SDL2\SDL.h"
|
#include "C:\Program Files\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\include\SDL2\SDL.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
//#include <SDL2/SDL_image.h>
|
|
||||||
#include <SDL2/SDL_mixer.h>
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
|
|||||||
@@ -49,20 +49,6 @@ void Text::init(LTexture *texture, SDL_Renderer *renderer, Uint8 height)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Escribe el texto en pantalla
|
|
||||||
void Text::write(int x, int y, std::string text)
|
|
||||||
{
|
|
||||||
Uint16 shift = 0;
|
|
||||||
for (Uint8 i = 0; i < text.length(); ++i)
|
|
||||||
{
|
|
||||||
mSprite->setSpriteClip(mOffset[int(text[i])].x, mOffset[int(text[i])].y, mSprite->getWidth(), mSprite->getHeight());
|
|
||||||
mSprite->setPosX(x + shift);
|
|
||||||
mSprite->setPosY(y);
|
|
||||||
mSprite->render();
|
|
||||||
shift += (mOffset[int(text[i])].w);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Escribe el texto en pantalla con kerning
|
// Escribe el texto en pantalla con kerning
|
||||||
void Text::write(int x, int y, std::string text, int kerning)
|
void Text::write(int x, int y, std::string text, int kerning)
|
||||||
{
|
{
|
||||||
@@ -78,7 +64,7 @@ void Text::write(int x, int y, std::string text, int kerning)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Escribe una cantidad determinada de caracteres del texto en pantalla
|
// Escribe una cantidad determinada de caracteres del texto en pantalla
|
||||||
void Text::write(int x, int y, std::string text, int kerning, Uint8 lenght)
|
void Text::write(int x, int y, std::string text, Sint8 kerning, Uint8 lenght)
|
||||||
{
|
{
|
||||||
Uint16 shift = 0;
|
Uint16 shift = 0;
|
||||||
for (Uint8 i = 0; i < lenght; ++i)
|
for (Uint8 i = 0; i < lenght; ++i)
|
||||||
|
|||||||
@@ -17,10 +17,16 @@ public:
|
|||||||
// Inicializador
|
// Inicializador
|
||||||
void init(LTexture *texture, SDL_Renderer *renderer, Uint8 height);
|
void init(LTexture *texture, SDL_Renderer *renderer, Uint8 height);
|
||||||
|
|
||||||
// Escribe el texto en pantalla
|
/**
|
||||||
void write(int x, int y, std::string text);
|
* \brief Escribe texto en pantalla
|
||||||
void write(int x, int y, std::string text, int kerning);
|
*
|
||||||
void write(int x, int y, std::string text, int kerning, Uint8 lenght);
|
* \param x Posición en el eje X donde empezar a escribir el texto
|
||||||
|
* \param y Posición en el eje Y donde empezar a escribir el texto
|
||||||
|
* \param string Texto para escribir
|
||||||
|
* \param kerning Espacio de separación entre letras
|
||||||
|
* \param lenght Longitud de la cadena de texto a escribir
|
||||||
|
*/
|
||||||
|
void write(int x, int y, std::string text, Sint8 kerning = 0, Uint8 lenght = 0);
|
||||||
|
|
||||||
// Escribe el texto con colores
|
// Escribe el texto con colores
|
||||||
void writeColored(int x, int y, std::string text, Uint8 R, Uint8 G, Uint8 B);
|
void writeColored(int x, int y, std::string text, Uint8 R, Uint8 G, Uint8 B);
|
||||||
|
|||||||
Reference in New Issue
Block a user