So I’m trying to play a texture atlas animation in reverse, but I just tried 'playReverse ( )'
on my texture atlas animation & it only played forward. What would be the way to do a reverse 'generateFrameNames ( )'
using 'this.anims.create ( )'
on the texture atlas? I tried negative anim speed, that didn’t work. I tried reversing the start & the end frames, that didn’t work.
I’m using a TexturePacker texture atlas. { Not multi-atlas. }
Any & all help is greatly appreciated!
Thank you!
Have a nice day!
You can do the anims this way:
this.anims.create({
key: 'player-run',
frames: [
{ key: 'player', frame: 'player-run_0' },
{ key: 'player', frame: 'player-run_1' },
{ key: 'player', frame: 'player-run_2' },
{ key: 'player', frame: 'player-run_3' },
{ key: 'player', frame: 'player-run_4' },
{ key: 'player', frame: 'player-run_5' },
{ key: 'player', frame: 'player-run_6' },
{ key: 'player', frame: 'player-run_7' },
{ key: 'player', frame: 'player-run_8' },
{ key: 'player', frame: 'player-run_9' },
],
frameRate: 9,
repeat: -1,
});
And so choose the order of frames
@BlunT76 - I use :
this.anims.create ( {
key : 'player-revive',
frames : this.anims.generateFrameNames (
'player', {
prefix : '004',
start : 0,
end : 9,
suffix : '.png',
}
),
frameRate : 10,
repeat : false,
} );
Instead of playing : '0040 - 0049'
, I need to play : '0049 - 0040'
So it would play ;
0049
0048
0047
0046
0045
0044
0043
0042
0041
0040
Yes, but if reversing start and end doesn’t work, you can do like me, and choose the order of each frame, my example is not reversed sorry
samme
April 21, 2020, 7:03pm
5
playReverse() works as described so I would double-check your code.
If you want to create a separate animation you can use this.anims.generateFrameNames(…).reverse()
.
1 Like
how do i use an if
statement to reverse or not reverse texture atlas animations?
Thank You!
samme
April 21, 2020, 11:58pm
7
Depending on whether you created one animation or two,
if (cond) { sprite.anims.play('player-revive'); }
else { sprite.anims.playReverse('player-revive'); }
// OR
if (cond) { sprite.anims.play('player-revive'); }
else { sprite.anims.play('player-revive-reverse'); }