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

New methods play & playReverse of Animation class #1287

Open
wants to merge 5 commits into
base: dev
Choose a base branch
from

Conversation

chengenzhao
Copy link
Contributor

Hi:

The animation class may need a play from current position method similar to the same name method of JavaFX Animation class.
And this will simplify the further development of AnimatedTextures.

#1244

compared to start & startReverse, play methods won't reset time when functions are called.
Similar to the same method in the Animation class of JavaFX
Also refactor playAnimationChannel method of AnimatedTexture class to adopt this change.
@codecov-commenter
Copy link

codecov-commenter commented Aug 8, 2023

Codecov Report

Attention: 9 lines in your changes are missing coverage. Please review.

Comparison is base (847bdd3) 59.69% compared to head (41755b4) 59.66%.

Files Patch % Lines
...main/kotlin/com/almasb/fxgl/animation/Animation.kt 0.00% 6 Missing ⚠️
.../kotlin/com/almasb/fxgl/texture/AnimatedTexture.kt 25.00% 3 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@             Coverage Diff              @@
##                dev    #1287      +/-   ##
============================================
- Coverage     59.69%   59.66%   -0.03%     
  Complexity     2961     2961              
============================================
  Files           308      308              
  Lines         15262    15271       +9     
  Branches       1561     1563       +2     
============================================
+ Hits           9111     9112       +1     
- Misses         5628     5636       +8     
  Partials        523      523              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

/**
* Plays Animation from current position in the direction indicated by rate.
*/
fun play(){
Copy link
Owner

Choose a reason for hiding this comment

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

I'm just wondering when this would be called. The current position in the animation can be controlled with pause/resume. isAnimating is always true when the animation is active. So the only way this is actually run is when the animation is fully stopped, meaning it matches the implementation of start. Does that make sense?

Copy link
Contributor Author

@chengenzhao chengenzhao Nov 2, 2023

Choose a reason for hiding this comment

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

let's say there is an AnimationChannel of wall clock starts from 0 to 12 clock
in the app, we want the clock animation starts from current time
so it would be nice to have

setTimeTo(currentTime)
play()

and later we may have

play(currentTime)//starts from currentTime
//or to more specific
playFrom(currentTime)

to replace the pure start() method
and later we may need playTo(specificPauseTime) method
and may have fluent method like

animation.setTimeTo(currentTime)
                .playTo(specificTime) //when it comes to specific time, it will pause
                .playReverseTo(anotherTimeEarlier) //like resume to another time
                .play(); //continue playing the rest animation
//or
animation.play(from: currentTime, to: specificTime) //play from current time to specific time, when it comes to specific time, animation will pause
                .playReverseTo(anotherTimeEarlier) //like resume to another time
                .play(); //continue playing the rest animation

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.

3 participants