-
-
Notifications
You must be signed in to change notification settings - Fork 95
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
Add Tweening framework. #352
Conversation
Adapt TweenEquations from the TweenEngine, drop the external dependency.
Refactor TweenFunctions. Allow setting relative tween targets.
Remove distinction between Particle color alpha and opacity.
The TweenEngine is accessible via Game.tweens()
Switch to ConcurrentHashMap instead of CopyOnWriteArrayList for managing Tweens in the TweenEngine.
…lly. Fix sloppy implementation of Image scaling in ImageComponent introduced in 4ff1076.
…nd creature velocity. Document Tweening package.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Document changes on
Particle
andIKeyboard
. - Adjust licensing and remove "unneccessary" easing functions.
TODO:
- Loopable Tweens
- Missing events of tweens
- Possibility to determine whether a
TweenType
is supported by aTweenable
Log warnings instead of crashing when the TweenType of a Tween is not implemented for a Tweenable. Remove external licenses in the TweenFunction enum as the functions have been reimplemented. Remove some tweening functions that are basically indistinguishable in many use cases.
Last change adressed these remarks:
|
It seems I came just a few hours too late to offer my feedback on this PR. First of all, the complete list of On the subject of the Second, it seems that Third, the It would also be useful to have an event listener for when a tween finishes. I'm sure I could find more ways to improve this API, but I haven't looked at it all that closely yet. Expect a PR shortly containing my proposed changes. |
You're very welcome to enhance this, it's been a bit of a rushed PR as we wanted to have a common ground for our project this month without overcomplicating the branching of the engine. |
This PR adds a package for interpolating values over time, offering predefined Easing functions defined by Robert Penner as well as the possibility to define custom mathematical tweening equations. If an object implements the
Tweenable
interface, it can override thegetTweenValues
andsetTweenValues
methods to define which attributes will be modified.Current examples for Tweenables are
Entities
(position, dimensions, angle, hitpoints, collision dimensions, velocity) andGuiComponent
s (position, dimensions, text angle), as well asSoundPlayback
s (volume).Each game has one instance of a
TweenEngine
which operates as a manager for all registeredTween
instances and applies theirTweenEquation
with each update. It can be retrieved usingGame.tweens()
.Tweens can be stopped, resumed, and reset, as the examples below show:
Apart from the Tweening framework, this PR implements the following changes: