Skip to content

Play animation backwards #2068

Answered by eonarheim
floAr asked this question in Q&A
Oct 27, 2021 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

Hi @floAr

I think the quickest way in the current version of Excalibur would be to create a new animation for the "closed" with the frames reversed. This is probably a good new feature to add to create a reversed animation, I'll make an issue for that shortly.

Give this a try

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

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@floAr
Comment options

Answer selected by floAr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants