Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: RepeatCount follows Roblox behaviour #173

Merged
merged 2 commits into from
Aug 30, 2022
Merged

fix: RepeatCount follows Roblox behaviour #173

merged 2 commits into from
Aug 30, 2022

Conversation

quantix-dev
Copy link
Contributor

@quantix-dev quantix-dev commented Jun 12, 2022

This is my suggested solution for issue #172

This pull request resolves this issue by adding one to the RepeatCount and using math.sign to get the signed result
this means that:
0 will be 1
and
-1 will be 0

I then add the absolute value of the RepeatCount onto this number, meaning
0 which was 1 will become 1
-1 which was 0 will become 1

This correctly creates the RepeatCount whilst ensuring that edge cases such as negative numbers or zero are resolved, to try to conform to the Roblox behaviour.

In order to accomplish the looping behaviour I ensure tweens that have a RepeatCount of -1 will always update their tween again by adjusting the if statement as so:
if currentTime > tween._currentTweenDuration and tween._currentTweenInfo.RepeatCount > -1 then

I realised this calculation was unneeded as the if statement that relies on numCycles will always be ignored when the RepeatCount is -1, so I reverted back to the previous fix of adding 1 to ensure 0 is properly supported
@quantix-dev quantix-dev marked this pull request as ready for review June 14, 2022 07:53
@dphfox dphfox merged commit e0604b9 into dphfox:main Aug 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants