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

Add support to Animations for Reversing the play #2069

Closed
eonarheim opened this issue Oct 28, 2021 · 0 comments · Fixed by #2070
Closed

Add support to Animations for Reversing the play #2069

eonarheim opened this issue Oct 28, 2021 · 0 comments · Fixed by #2070
Labels
proposal Applied to issues that are a proposal for an implementation

Comments

@eonarheim
Copy link
Member

Context

In the current state, you must reverse the animation frames to reverse the order of animation. See discussion

// Pseudo code
const forwards = ex.Animation({...}); // animation that ends
const backwards = forwards.clone();
backwards.frames.reverse(); // reverses in place, okay because clone() creates a new frames list so the 'forwards' animation should be fine

const actor = new ex.Actor({...});
actor.graphics.use(forwards);
forwards.events.on('end', () => {
   actor.graphics.use(backwards);
});

Proposal

Add a property or method to reverse the direction of play.

Possilbly? API design notes welcome

const animation = new ex.Animation({...});
animation.reverse(); // reverse the play direction

animation.direction; // Forwards or backwards sentinel
@eonarheim eonarheim added the proposal Applied to issues that are a proposal for an implementation label Oct 28, 2021
eonarheim added a commit that referenced this issue Oct 28, 2021
Closes #2069

## Changes
- Adds `.reverse()` to animations
- Adds an optional `reverse: true` to the constructor bag
- Inspect the play direction with `.direction` and new enum
- New unit tests
eonarheim added a commit that referenced this issue Oct 29, 2021
Closes #2069

## Changes
- Adds `.reverse()` to animations
- Adds an optional `reverse: true` to the constructor bag
- Inspect the play direction with `.direction` and new enum
- New unit tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
proposal Applied to issues that are a proposal for an implementation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant