Skip to content

Commit

Permalink
Fixed a division by zero error
Browse files Browse the repository at this point in the history
  • Loading branch information
Hurricaaane committed Aug 3, 2014
1 parent d19da4c commit ba261f2
Showing 1 changed file with 20 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,21 +59,37 @@ public float calculateFadeFactor()
long curTime = this.time.getMilliseconds();
if (this.foLast)
{
this.fade = 1 - (curTime - this.fadeOutTime) / (float) this.fadeOutDuration;
if (this.fade < 0f)
if (this.fadeOutDuration <= 0f)
{
this.fade = 0f;
this.complete = true;
}
else
{
this.fade = 1 - (curTime - this.fadeOutTime) / (float) this.fadeOutDuration;
if (this.fade < 0f)
{
this.fade = 0f;
this.complete = true;
}
}
}
else
{
this.fade = (curTime - this.fadeInTime) / (float) this.fadeInDuration;
if (this.fade > 1f)
if (this.fadeInDuration <= 0f)
{
this.fade = 1f;
this.complete = true;
}
else
{
this.fade = (curTime - this.fadeInTime) / (float) this.fadeInDuration;
if (this.fade > 1f)
{
this.fade = 1f;
this.complete = true;
}
}
}

return this.fade;
Expand Down

0 comments on commit ba261f2

Please sign in to comment.