Sprite: Se peude establecer el nivel de zoom en ancho y alto
This commit is contained in:
@@ -98,6 +98,7 @@ Text::Text(string textFile, string bitmapFile, SDL_Renderer *renderer)
|
||||
|
||||
// Inicializa variables
|
||||
fixedWidth = false;
|
||||
zoom = 1;
|
||||
}
|
||||
|
||||
// Constructor
|
||||
@@ -121,6 +122,7 @@ Text::Text(string textFile, Texture *texture, SDL_Renderer *renderer)
|
||||
|
||||
// Inicializa variables
|
||||
fixedWidth = false;
|
||||
zoom = 1;
|
||||
}
|
||||
|
||||
// Constructor
|
||||
@@ -141,6 +143,7 @@ Text::Text(textFile_t *textFile, Texture *texture, SDL_Renderer *renderer)
|
||||
|
||||
// Inicializa variables
|
||||
fixedWidth = false;
|
||||
zoom = 1;
|
||||
}
|
||||
|
||||
// Destructor
|
||||
@@ -168,7 +171,7 @@ void Text::write(int x, int y, string text, int kerning, int lenght)
|
||||
sprite->setPosY(y);
|
||||
sprite->render();
|
||||
// shift += (offset[int(text[i])].w + kerning);
|
||||
shift += fixedWidth ? boxWidth : (offset[int(text[i])].w + kerning);
|
||||
shift += fixedWidth ? boxWidth * zoom : (offset[int(text[i])].w + kerning) * zoom;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -266,4 +269,24 @@ void Text::reLoadTexture()
|
||||
void Text::setFixedWidth(bool value)
|
||||
{
|
||||
fixedWidth = value;
|
||||
}
|
||||
|
||||
// Establece el tamaño del zoom
|
||||
void Text::setZoom(int value)
|
||||
{
|
||||
if (value < 1)
|
||||
{
|
||||
value = 1;
|
||||
}
|
||||
zoom = value;
|
||||
sprite->setZoomW(zoom);
|
||||
sprite->setZoomH(zoom);
|
||||
}
|
||||
|
||||
// Quita el zoom
|
||||
void Text::disableZoom()
|
||||
{
|
||||
zoom = 1;
|
||||
sprite->setZoomW(zoom);
|
||||
sprite->setZoomH(zoom);
|
||||
}
|
||||
Reference in New Issue
Block a user