Skip to content

Add remaining FlixelTweenTypes LOOPING, PINGPONG and BACKWARD#58

Draft
jfsaaved wants to merge 7 commits intostringdotjar:developfrom
jfsaaved:feature/sub-issue-38-remaining_tweens
Draft

Add remaining FlixelTweenTypes LOOPING, PINGPONG and BACKWARD#58
jfsaaved wants to merge 7 commits intostringdotjar:developfrom
jfsaaved:feature/sub-issue-38-remaining_tweens

Conversation

@jfsaaved
Copy link

@jfsaaved jfsaaved commented Mar 7, 2026

Issue: #38

  • Add LOOPING, PINGPONG, and BACKWARD to FlixelTweens
  • Add active variable
  • Add delayToUse variable
  • Add waitingForRestart variable

Description

The goal is to include the BACKWARD, LOOPING and PINGPONG tween types to allow further control of the tweening system.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactor / Optimization

Checklist

  • My PR targets the develop branch, not master/main.
  • My code follows the code style of this project.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • My changes pass all automated build checks.
  • I have updated the documentation accordingly (if applicable).
  • I have added tests that prove my fix is effective or that my feature works.

Screenshots / Evidence (if applicable)

PINGPONG
looping_flixel

LOOPING
pingpong_flixel

BACKWARD
backward_flixel

- AddLOOPING, PINGPONG, and BACKWARD to FlixelTweens
- Add active variable
- Add delayToUse variable
- Add waitingForRestart variable
jfsaaved added 4 commits March 7, 2026 06:39
- Fix FlixelPropertyTween math for new value
- Revert changes on FlixelTween update
- Add begind for snapshotarray
…nto feature/sub-issue-38-remaining_tweens
@jfsaaved jfsaaved marked this pull request as draft March 7, 2026 12:49
@jfsaaved jfsaaved marked this pull request as ready for review March 7, 2026 12:50
@stringdotjar stringdotjar moved this from 🗒️ Todo to 🏗️ In Progress in FlixelGDX Project Board Mar 7, 2026
/** Default constructor for pooling purposes. */
protected FlixelTween() {}
protected FlixelTween() {
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 */
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 */
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a question mark at the end for proper punctuation

return globalManager;
}

public FlixelTweenManager getManager() {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert this back

return waitingForRestart;
}

public FlixelTween setManager(FlixelTweenManager newManager) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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<>();
Copy link
Owner

@stringdotjar stringdotjar Mar 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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();
}

/**
Copy link
Owner

@stringdotjar stringdotjar Mar 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 Boolean with boolean, as we are not expecting an object!
  • Add braces to the if (tween == null) statement. We typically only need to use one-line if statements if we need to do multiple checks in an area, in which one liners would become more readable rather than braces

}
}

/**
Copy link
Owner

@stringdotjar stringdotjar Mar 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix Javadoc grammar (add a period) and put brace on same line as the method for consistency

return tween;
}

/**
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@stringdotjar stringdotjar added enhancement New feature or request core Core logic module of the framework tweening Custom tweening system for adding animations on objects labels Mar 7, 2026
@stringdotjar stringdotjar changed the title [WIP] Adding remaining FlixelTweens - LOOPING, PINGPONG, BACKWARD Add remaining FlixelTweens LOOPING, PINGPONG and BACKWARD Mar 7, 2026
@stringdotjar stringdotjar changed the title Add remaining FlixelTweens LOOPING, PINGPONG and BACKWARD Add remaining FlixelTweenTypes LOOPING, PINGPONG and BACKWARD Mar 7, 2026
activeTweens.removeValue(tween, true);

if (destroy) {
tween.destroy();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this line here, as when you call tweenPool.free(), it automatically calls reset(), in which inside of FlixelTween.reset(), it should call destroy()

Copy link
Owner

@stringdotjar stringdotjar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 .editorconfig file. 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 x field start at 0f, and it's being tweened to 400f, and it was cancelled and restarted at 200f, it should restart and begin at 200f, not back from 0f. This applies to all tween types
  • Refactor destroy() to use the reset() method and replace the resetBasic() call in reset() to use destroy(), 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
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add spaces after the if keywords

@stringdotjar stringdotjar added the needs changes This pull request needs changes before it can be merged label Mar 7, 2026
@stringdotjar stringdotjar moved this from 🏗️ In Progress to Needs Improvements in FlixelGDX Project Board Mar 8, 2026
@stringdotjar stringdotjar marked this pull request as draft March 8, 2026 20:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Core logic module of the framework enhancement New feature or request needs changes This pull request needs changes before it can be merged tweening Custom tweening system for adding animations on objects

Projects

Status: 🔧 Needs Changes

Development

Successfully merging this pull request may close these issues.

2 participants