"How to play" added

This commit is contained in:
2021-04-05 19:07:33 +02:00
parent 36bb6b8fe8
commit 2330820a15
4 changed files with 95 additions and 36 deletions

View File

@@ -216,6 +216,25 @@ void Text::writeCentered(int x, int y, std::string text, int kerning)
}
}
// Escribe el texto centrado en un punto x y con kerning
void Text::writeCenteredAndColored(int x, int y, std::string text, int kerning, Uint8 R, Uint8 G, Uint8 B)
{
mSprite->getTexture()->setColor(R, G, B);
x = x - (Text::lenght(text, kerning) / 2);
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 + kerning);
}
mSprite->getTexture()->setColor(255, 255, 255);
}
// Obtiene la longitud en pixels de una cadena
Uint16 Text::lenght(std::string text, int kerning)
{