Añadido delay final al fade
This commit is contained in:
@@ -34,6 +34,8 @@ void Fade::init()
|
||||
r = 0;
|
||||
g = 0;
|
||||
b = 0;
|
||||
postDuration = 20;
|
||||
postCounter = 0;
|
||||
numSquaresWidth = param->numSquaresWidth;
|
||||
numSquaresHeight = param->numSquaresHeight;
|
||||
fadeRandomSquaresDelay = param->fadeRandomSquaresDelay;
|
||||
@@ -149,7 +151,14 @@ void Fade::update()
|
||||
|
||||
if (finished)
|
||||
{
|
||||
enabled = false;
|
||||
if (postCounter == postDuration)
|
||||
{
|
||||
enabled = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
postCounter++;
|
||||
}
|
||||
}
|
||||
|
||||
counter++;
|
||||
@@ -162,6 +171,7 @@ void Fade::activate()
|
||||
enabled = true;
|
||||
finished = false;
|
||||
counter = 0;
|
||||
postCounter = 0;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
@@ -204,15 +214,10 @@ void Fade::activate()
|
||||
int num = numSquaresWidth * numSquaresHeight;
|
||||
while (num > 1)
|
||||
{
|
||||
// agafa un nombre aleatòri entre 0 i num-1
|
||||
int num_arreu = rand() % num;
|
||||
|
||||
// el element triat el swapechem amb l'ultim
|
||||
SDL_Rect temp = square[num_arreu];
|
||||
square[num_arreu] = square[num - 1];
|
||||
square[num - 1] = temp;
|
||||
|
||||
// I ara queda un element menys per desordenar
|
||||
num--;
|
||||
}
|
||||
break;
|
||||
@@ -229,7 +234,8 @@ bool Fade::isEnabled()
|
||||
// Comprueba si ha terminado la transicion
|
||||
bool Fade::hasEnded()
|
||||
{
|
||||
return finished;
|
||||
// Ha terminado cuando ha finalizado la transición y se ha deshabilitado
|
||||
return !enabled && finished;
|
||||
}
|
||||
|
||||
// Establece el tipo de fade
|
||||
@@ -244,4 +250,10 @@ void Fade::setColor(Uint8 r, Uint8 g, Uint8 b)
|
||||
this->r = r;
|
||||
this->g = g;
|
||||
this->b = b;
|
||||
}
|
||||
|
||||
// Establece la duración posterior
|
||||
void Fade::setPost(int value)
|
||||
{
|
||||
postDuration = value;
|
||||
}
|
||||
Reference in New Issue
Block a user