ippa / jaws

Jaws - HTML5 canvas javascript 2D Game Framework
https://jawsjs.ippa.se
GNU Lesser General Public License v3.0
364 stars 75 forks source link

Setting the frame_direction property of an animation to -1 causes the animation to loop on the first frame. #76

Closed DanMacDonald closed 11 years ago

DanMacDonald commented 11 years ago

The current code in the animation.update() function looks like this...

else if(this.loop) {
    this.index = 0
}

If you change the code to look like this in the "loop" clause, reversed animations will play correctly

   else if(this.loop) {
      if(this.frame_direction < 0) { 
        this.index = this.frames.length -1; 
      } else { 
        this.index = 0; 
      }
    }
ippa commented 11 years ago

Nice find, can you make a pull-request and maybe a simple test-case for it? :)

DanMacDonald commented 11 years ago

Sure! https://github.com/ippa/jaws/pull/77

Thanks for this cool little API, I'm enjoying it. :)