Add remaining FlixelTweenTypes LOOPING, PINGPONG and BACKWARD#58
Add remaining FlixelTweenTypes LOOPING, PINGPONG and BACKWARD#58jfsaaved wants to merge 7 commits intostringdotjar:developfrom
Conversation
- AddLOOPING, PINGPONG, and BACKWARD to FlixelTweens - Add active variable - Add delayToUse variable - Add waitingForRestart variable
- Fix FlixelPropertyTween math for new value - Revert changes on FlixelTween update - Add begind for snapshotarray
…nto feature/sub-issue-38-remaining_tweens
| /** Default constructor for pooling purposes. */ | ||
| protected FlixelTween() {} | ||
| protected FlixelTween() { | ||
| } |
There was a problem hiding this comment.
Please revert the brace back to be on one line
| var type = tweenSettings.getType(); | ||
|
|
||
| if (type.equals(FlixelTweenType.LOOPING) || type.equals(FlixelTweenType.PINGPONG)) { | ||
| if (type.equals(FlixelTweenType.PINGPONG)) |
There was a problem hiding this comment.
Please put the brace on the same line for consistency
| onComplete.run(this); | ||
| } | ||
| // If it's not PERSIST, remove tween from activeTweens and set to active = false | ||
| if (type.equals(FlixelTweenType.ONESHOT) || type.equals(FlixelTweenType.BACKWARD) && manager != null) |
There was a problem hiding this comment.
Please put the brace on the same line for consistency
|
|
||
| /** Is {@code this} tween currently active? */ | ||
| public boolean running = false; | ||
| /** Is {@code this} tween active */ |
There was a problem hiding this comment.
Please add a question mark at the end for proper punctuation
| /** Is {@code this} tween active */ | ||
| protected boolean active = false; | ||
|
|
||
| /** Is {@code this} tween waiting for a restart */ |
There was a problem hiding this comment.
Please add a question mark at the end for proper punctuation
| return globalManager; | ||
| } | ||
|
|
||
| public FlixelTweenManager getManager() { |
| return waitingForRestart; | ||
| } | ||
|
|
||
| public FlixelTween setManager(FlixelTweenManager newManager) { |
There was a problem hiding this comment.
Nice j*b moving the remove logic to the manager class, although you can make this method simpler using the @NotNull annotation, so that way you don't have to do if (newManager == null)
| FlixelTween tween = tweens[i]; | ||
| if (tween == null) { | ||
| FlixelTween[] items = activeTweens.begin(); | ||
| ArrayList<FlixelTween> finishedTweens = new ArrayList<>(); |
There was a problem hiding this comment.
Do not create new objects inside the update loop, as that will cause the framerate to stutter. You can condense this into a single for loop without having to create a new ArrayList every frame
| activeTweens.end(); | ||
| } | ||
|
|
||
| /** |
There was a problem hiding this comment.
Please do the following:
- Add proper grammar in the Javadoc (a sentence ends with a period) and be a little more descriptive. It should read as (
Remove an {@link FlixelTween} from {@code this} manager. Note that when the tween is removed, it will call {@link FlixelTween#destroy} and it can no longer be used.) - Replace the typo
Booleanwithboolean, as we are not expecting an object! - Add braces to the
if (tween == null)statement. We typically only need to use one-lineifstatements if we need to do multiple checks in an area, in which one liners would become more readable rather than braces
| } | ||
| } | ||
|
|
||
| /** |
There was a problem hiding this comment.
Please fix Javadoc grammar (add a period) and put brace on same line as the method for consistency
| return tween; | ||
| } | ||
|
|
||
| /** |
There was a problem hiding this comment.
As said in the comment for removeTween(), please fix the Javadoc and formatting + be a little more descriptive
Also, rename it to simply addTween(FlixelTween tween), as it will still imply the same idea
| activeTweens.removeValue(tween, true); | ||
|
|
||
| if (destroy) { | ||
| tween.destroy(); |
There was a problem hiding this comment.
Remove this line here, as when you call tweenPool.free(), it automatically calls reset(), in which inside of FlixelTween.reset(), it should call destroy()
stringdotjar
left a comment
There was a problem hiding this comment.
Nice job! There's just a few things to do left you need to do before I merge it into the codebase:
- Fix your formatting to match what's in the
.editorconfigfile. Remember, we want the codebase to look like it was written by a single person - Update the Javadocs and your comments as stated in the GitHub comments I left
- When the tween restarts, it goes back to the starting values where the tween started at before the tween started. This should not happen. For example, if a sprite had its
xfield start at0f, and it's being tweened to400f, and it was cancelled and restarted at200f, it should restart and begin at200f, not back from0f. This applies to all tween types - Refactor
destroy()to use thereset()method and replace theresetBasic()call inreset()to usedestroy(), as we want both methods to do the same thing for backwards compatibility
| // resetToBasic won't work for LOOPING & PINGPONG, hence removed it and switched vars manually | ||
| waitingForRestart = false; | ||
| var type = this.getTweenSettings().getType(); | ||
| if(!type.equals(FlixelTweenType.PINGPONG)) { // If it's PINGPONG use the finish() backward variable instead of resetting it here |
There was a problem hiding this comment.
Please add spaces after the if keywords
Issue: #38
Description
The goal is to include the BACKWARD, LOOPING and PINGPONG tween types to allow further control of the tweening system.
Type of Change
Checklist
Screenshots / Evidence (if applicable)
PINGPONG

LOOPING

BACKWARD
