Merge pull request #629 from DelinWorks/motion-streak-fps-fix

[FIX] Motion streak vsync off crash
This commit is contained in:
一线灵 2022-05-04 16:08:51 +08:00 committed by GitHub
commit 77bd96afb0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 1 deletions

View File

@ -101,7 +101,12 @@ bool MotionStreak::initWithFade(float fade, float minSeg, float stroke, const Co
_stroke = stroke; _stroke = stroke;
_fadeDelta = 1.0f / fade; _fadeDelta = 1.0f / fade;
double fps = 1 / _director->getAnimationInterval(); // Fix #629 Motion streak vsync off crash
double interval = _director->getAnimationInterval();
double fps = 1 / interval;
if (roundf(fps) > 240.0)
fps = 240.0;
_maxPoints = (int)(fade * fps) + 2; _maxPoints = (int)(fade * fps) + 2;
_pointState = (float*)malloc(sizeof(float) * _maxPoints); _pointState = (float*)malloc(sizeof(float) * _maxPoints);