# How to control animation frames order

**URL:** <https://phaser.discourse.group/t/how-to-control-animation-frames-order/9419>\
**Category:** Phaser 3\
**Created:** [April 28, 2021, 2:46pm UTC](https://phaser.discourse.group/t/how-to-control-animation-frames-order/9419 "2021-04-28T14:46:57Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![knighter](https://avatars.discourse-cdn.com/v4/letter/k/71e660/32.png) [@knighter](https://phaser.discourse.group/u/knighter)\
**Post date:** [April 28, 2021, 2:46pm UTC](https://phaser.discourse.group/t/how-to-control-animation-frames-order/9419/1 "2021-04-28T14:46:57Z")

</div>

There is an animated sprite with `animationupdate` event handler:

`sprite.on('animationupdate', (anim, frame) => onAnimationUpdateHandler(sprite, anim, frame));`

How I can change current frame on started animation inside that event handler?

I found a setCurrentFrame method in Phaser Docs ([Phaser 3 API Documentation - Class: Animation](https://photonstorm.github.io/phaser3-docs/Phaser.GameObjects.Components.Animation.html)), but I do not understand how to use it.

---

<div class="post-metadata">

**Author:** ![samme](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/samme/32/5275_2.png) [@samme](https://phaser.discourse.group/u/samme)\
**Post date:** [April 28, 2021, 5:54pm UTC](https://phaser.discourse.group/t/how-to-control-animation-frames-order/9419/2 "2021-04-28T17:54:23Z")

</div>

What are you trying to do overall?

Possible you want to use the `startAt` argument in `play()` instead.

---

<div class="post-metadata">

**Author:** ![knighter](https://avatars.discourse-cdn.com/v4/letter/k/71e660/32.png) [@knighter](https://phaser.discourse.group/u/knighter)\
**Post date:** [April 28, 2021, 10:30pm UTC](https://phaser.discourse.group/t/how-to-control-animation-frames-order/9419/3 "2021-04-28T22:30:40Z")

</div>

I need to change frames order from “1-2-3-4-5-6”  
to “1-2-3-4-3-4-3-4-5-6” (e.g.) in some cases.  
New frames order can be different and depends on algorithm.

---

<div class="post-metadata">

**Author:** ![samme](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/samme/32/5275_2.png) [@samme](https://phaser.discourse.group/u/samme)\
**Post date:** [April 29, 2021, 3:27pm UTC](https://phaser.discourse.group/t/how-to-control-animation-frames-order/9419/4 "2021-04-29T15:27:20Z")

</div>

```javascript
sprite.anims.setCurrentFrame(anim.getFrameAt(index));

```

---

<div class="post-metadata">

**Author:** ![knighter](https://avatars.discourse-cdn.com/v4/letter/k/71e660/32.png) [@knighter](https://phaser.discourse.group/u/knighter)\
**Post date:** [May 1, 2021, 2:27am UTC](https://phaser.discourse.group/t/how-to-control-animation-frames-order/9419/5 "2021-05-01T02:27:00Z")

</div>

Thanks!  
Method `getFrameAt` is private, but it’s nothing.
