hyperandroid / CAAT

Canvas Advanced Animation Toolkit
hyperandroid.github.com/CAAT
MIT License
727 stars 117 forks source link

CAAT.SpriteImage.setSpriteIndexAtTime #77

Closed iaincarsberg closed 11 years ago

iaincarsberg commented 11 years ago

Hey, hyperandroid

I've found a bug, and a solution, not sure which file to edit to submit a patch, but if you look at...

https://github.com/hyperandroid/CAAT/blob/master/build/caat.js#L13320

Imho this should be: this.spriteIndex = this.animationImageIndex[0];

Use case for the bug Your using a sprite sheet for your animations, thats set using ".setAnimationImageIndex([0, 1, 2, 3])", then after a period of time you want to switch to another animation index, via ".setAnimationImageIndex([4, 5, 6, 7])", currently for a few ms its switching to the 0th frame, before entering the frame at index 4.

Thanks Iain

hyperandroid commented 11 years ago

There's a method called resetAnimationTime(). Could you give it a try and let me know whether this fixes it ?

hyperandroid commented 11 years ago

That call has been added to setAnimationImageIndex. Could you try with a fresh CAAT version instead the previous ?

Phloog commented 11 years ago

This bug still exists in caat.js Version: 0.4 build: 278.

Patch:

13704c13704

< this.spriteIndex=0;

> this.spriteIndex=this.animationImageIndex[0];

...the bug is very annoying when animating a spriteImage that was initialized with a map created by the online tile tool, because the 0th frame then is the whole packed texture with all sprites! ;)

So - the patch posted above fixes the issue.

Cheers, Phloog

hyperandroid commented 11 years ago

Fixed. Thank you.

hyperandroid commented 11 years ago

ghthor, thanks for sending the patch. Will be fixed in the next revision, this week.