59 lines
1.5 KiB
C++
59 lines
1.5 KiB
C++
#pragma once
|
|
#include "sprite.h"
|
|
|
|
#ifndef TEXT_H
|
|
#define TEXT_H
|
|
|
|
// Clase texto. Pinta texto en pantalla a partir de un bitmap
|
|
class Text
|
|
{
|
|
public:
|
|
// Constructor
|
|
Text();
|
|
|
|
// Destructor
|
|
~Text();
|
|
|
|
// Inicializador
|
|
void init(LTexture *texture, SDL_Renderer *renderer, Uint8 height);
|
|
|
|
/**
|
|
* \brief Escribe texto en pantalla
|
|
*
|
|
* \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
|
|
void writeColored(int x, int y, std::string text, Uint8 R, Uint8 G, Uint8 B);
|
|
|
|
// Escribe el texto centrado en un punto x y con kerning
|
|
void writeCentered(int x, int y, std::string text, int kerning);
|
|
|
|
// Obtiene la longitud en pixels de una cadena
|
|
Uint16 lenght(std::string text, int kerning);
|
|
|
|
// Obtiene el valor de la variable
|
|
Uint8 getType();
|
|
|
|
// Establece el valor de la variable
|
|
void setType(Uint8 type);
|
|
|
|
// Obtiene el valor de la variable
|
|
Uint8 getSize();
|
|
|
|
// Establece el valor de la variable
|
|
void setSize(Uint8 size);
|
|
|
|
private:
|
|
Sprite *mSprite; // Objeto con los graficos para el texto
|
|
SDL_Rect mOffset[255]; // Vector con las posiciones y ancho de cada letra
|
|
Uint8 mHeight; // Altura del texto
|
|
};
|
|
|
|
#endif
|